[R] Problems with .C - [Ff]ree()?
Mark White
mark at celos.net
Tue Jan 15 19:04:29 CET 2002
Prof Brian Ripley writes:
> On Mon, 14 Jan 2002, Thomas Lumley wrote:
> > No. I tried
> > repeat({
> > print(.C("R_test",as.character("filename"), integer(100000),
> > complex(100000))[[1]])
> > })
> >
> > with no problems. (I also tried without <stdlib.h> and without the
> > unnecessary cast to double * on the malloc, for the sake of variety).
I also tried this: no problems for me with this small
example, either, only dies when called from my R library
code. Maybe R needs to be doing something specific between
the .C calls? I'll see if I can extract a complete chunk of
R code from my library which repeatably causes problems.
> > I could see this happening if you somehow had two different malloc()s
> > around, but I can't see how you could.
Just as a sanity check, I tried it on a Sparc using the Sun
compiler suite; no problems at all.
> It's a common symptom on some systems of writing off the end of an
> allocated block, and that is normally R-version-sensitive. OTOH, I use
> Calloc/Free all the time and on correct code never see this. I was just
> wondering about the use of Rcomplex. That's a structure and unusual in R.
> .C is copying arguments to and from the call to the C code, and I'm
> wondering if the compiler used here is handling arrays of structures
> correctly.
I tried changing it to (double) at both ends; it still
causes near-certain death.
> There are lot of broken gcc's about in Linux distributions
> ....
This is gcc 2.95.3 on NetBSD -current (new toolchain), on
Intel; a broken gcc or malloc is far from impossible, but
I'd have thought something (like the kernel, or even some
other session of R) would have misbehaved by now if so.
Mark <><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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