[R] Segmentation fault

Göran Broström gb at stat.umu.se
Sun Nov 4 15:51:48 CET 2001


On 4 Nov 2001, Peter Dalgaard BSA wrote:

> Göran Broström <gb at stat.umu.se> writes:
> 
> > Dear R-afficionados,
> > 
> > I have made a package that uses compiled C code, and I use the
> > Calloc/Free mechanism in that code. When I run a function calling 
> > the C code, everything is fine, but when I run it once more I get
> > ('R -d gdb', RH 7.2, R-1.3.1):
> > 
> > > te()
> > 
> > Program received signal SIGSEGV, Segmentation fault.
> > RunGenCollect (size_needed=41992) at memory.c:1007
> > 1007			SEXP next = NEXT_NODE(s);
> > 
> > My guess is that I haven't Free'd enough in the C code. Before I start
> > searching, I would like to have an expert opinion. Could the reason be 
> > something else?
> 
> That should just give you a memory leak where some memory is not
> returned to the system.
> 
> More likely, you Free'd something that wasn't Calloc'd...
> 
> You might want to try a gc() immediately after the first call to te()

I actually did, and that also gave a segfault.

> or turning on gctorture().

I'm just trying that (it runs very slow now!).
I will also follow Brian's advise, to check pointers before Free'ing them!  

Thanks a lot for all the advise!

Göran

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