[Rd] Garbage collector crashes after calling a C function

Antonio, Fabio Di Narzo antonio.fabio at gmail.com
Wed Mar 7 12:59:54 CET 2007


2007/3/7, Sole Acha, Xavi <x.sole at iconcologia.net>:
> Dear listers,
>
>
>
> a few days ago I asked a question about a problem I had with a C function programmed by myself to be called from R. Thanks to your help, I have been able to look a bit further into it, so now I can be a bit more specific when telling what happens.
>
>
>
> The fact is that, when my C function finishes its execution (after calling it via the ".C" interface), R seems ok but then crashes when the garbage collector executes, giving a segmentation fault.
>
>
>
> As some of you suggested, I have executed my function with valgrind, and I get no memory errors, but some memory leaks (which I am not able to locate although compiling my program with the -c flag),

In gcc, maybe you mean the '-g' flag

> and I also get the memory error from RunGenCollect: (which I suppose is causes the segmentation fault). You can see a small piece of the valgrind output below
>
>
>
> Using gctorture to make the garbage collector crash inside the execution of my program didn't work (my program finished). The question is: what are the typical programming errors that can make R garbage collector crash? Could it be because of these memory leaks? If so, how could I trace them? I have tried it, but running my program with gdb is not an easy task to do, as it performs a huge number of iterations.
>
>
>
> Thank you very much in advance for your help. I would appreciate any hint that could help me solve this tricky problem.
>
>
>
> Best regards,
>
>
>
> Xavier Solé.
>
>
>
> -----------
>
> ### This is one of the memory leaks
>
> ==9370== 162 (160 direct, 2 indirect) bytes in 1 blocks are definitely lost in loss record 11 of 42
>
> ==9370==    at 0x4A19D35: malloc (vg_replace_malloc.c:149)
>
> ==9370==    by 0x84490E0: ???
>
> ==9370==    by 0x844D346: ???
>
> ==9370==    by 0x4BBE1A2: do_dotCode (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BE9035: Rf_eval (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BEBA3F: do_set (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BE8E5E: Rf_eval (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BEAF0D: do_begin (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BE8E5E: Rf_eval (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BE9711: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BE9107: Rf_eval (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BEBA3F: do_set (in /usr/lib64/R/lib/libR.so)
>
>
>
> ### This is the RunGenCollect memory error
>
> ==9370== Invalid write of size 8
>
> ==9370==    at 0x4C1F73A: RunGenCollect (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4C23E55: R_gc_internal (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4C22DC3: Rf_cons (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4C23AE1: Rf_allocList (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4B6926B: installAttrib (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4B69961: Rf_classgets (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4B68DC1: Rf_setAttrib (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4B69A40: do_classgets (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BE908E: Rf_eval (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BEB6FD: applydefine (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BEBAE3: do_set (in /usr/lib64/R/lib/libR.so)
>
> ==9370==    by 0x4BE8E5E: Rf_eval (in /usr/lib64/R/lib/libR.so)
>
> ==9370==  Address 0x10 is not stack'd, malloc'd or (recently) free'd
>
>
>
>
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>


-- 
Antonio, Fabio Di Narzo
Ph.D. student at
Department of Statistical Sciences
University of Bologna, Italy



More information about the R-devel mailing list