[R] segfault when calling C code

Matthew Wiener mcw at ln.nimh.nih.gov
Fri Jan 5 03:51:15 CET 2001


Hi, all.

I've got some C code that I've used successfully, and fairly extensively,
in R-1.1.1, which is suddenly causing segmentation faults in R-1.2.0.  The
original code used calloc (just plain calloc) with a free at the end, but
I've tried replacing the calloc with R_alloc (based on the Writing R
extensions documentation, which I'm not sure I've understood properly),
and also passing in variables with enough space (I know how much it will
be).  Neither change gets rid of the segmentation fault.

In case it helps, here's one of the 2 callocs (the other is identical,
with a different name):

trunccdfs = (double *) calloc(*nbins * *nconds, sizeof(double));

Before jumping in with a debugger (and running R with debugging for the
first time) I thought I'd see whether this rang any bells with anyone.
Again, the part that confuses me (but that may be the clue as to what's
wrong) is that this code worked fine with R-1.1.1.

If more details would be helpful I'd be happy to provide them.  This
message is, as I said, just in case this is a common problem in the
transition to R-1.2.0.

Thanks,

Matt Wiener
Laboratory of Neuropsychology 
National Institutes of Health
Bethesda, MD  20892


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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