[R] segfault when calling C code
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Fri Jan 5 08:42:30 CET 2001
On Thu, 4 Jan 2001, Matthew Wiener wrote:
> 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.
What platform?
We saw a few examples in which array over-runs caused problems with 1.2.0
and not 1.1.1. I also saw a couple of Windows-specific problems.
The `free' in 1.1.1 was very robust (mainly because it didn't free
quite often), and that used in 1.2.0 is less so.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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