R-beta: Segmentation fault

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Aug 24 16:14:30 CEST 1998

Jarle Tufto <jarlet at math.ntnu.no> writes:

> In R (on a linux platform), everything seems to work
> smoothly (no memory buildup according to gc() ), except that
> I, every now and then, get the error message "Segmentation
> fault - core dumped".  I haven't quite figured out which
> part of my code is generating the problem; the error
> actually seems to pop up at different places in my code
> depending on the exact history of the R-session - which I
> find very strange.  Also, if run exactly the same sequence
> of commands in two separate R-sessions, R terminates at
> exactly the same point.
> Could it possibly it is something going on inside R which is
> causing the problem?  Or that I have a hardware problem??

These crashes usually happen due to a weakness in the R memory
management model: If you look in almost any source file, you'll see a
lot of PROTECT()...UNPROTECT() constructions, which are there to
protect temporary objects from garbage collection. If one forgets one
of those, nothing bad happens, *until* GC is triggered at exactly the
wrong moment. Human nature being what it is, a handful of such errors
have slipped in, and a new one pops up from time to time.

Although the bugs can still be elusive, they can be spotted using a
debugger, once one has a set of data that is known to generate the

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list