[Rd] segfault after .C call.

Adrin adrin.jalali at gmail.com
Tue Oct 4 23:49:18 CEST 2011

Hi there,

I think I'm encountering a bug, and I already reported it here:

But meanwhile, could you help me by any suggestions about the problem?

I'll place the content of the reported bug here. You can find
attachments on bugzilla if you were that generous to check it for me.

Best and Thanks in Advance,

Bug report content:

I have a C/C++ code and I'm calling a function from that code using .C

I did check for memory leak in my C code using valgrind and the output of that
is attached. But when I run the same code from R, I get segfault in older
versions immediately. In 2.13.2 I will get an exception when I run gc() right
after my R script.

Reproduction steps:

1. extract the prj.tar.gz
2. call test.R from the src directory inside the package (source("test.R").
That will compile the C code if the .so file is not up to date.
3. even call something like gc(), or call test.R again.

To reproduce the valgrind output of the C code itself:

1. compile the code. To do that you can run the following g++ command within
the src directory:

g++ -m64 -I/usr/include/R -I/usr/local/include -fpic -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic kbest.cpp

2. Run the valgrind from the src directory like this:

valgrind --leak-check=full ./a.out ../data/Signs.csv ../data/Pvals.csv
2120000000 2

More information about the R-devel mailing list