The bug is in your code! (I see at least one - many buffer overflows in all
char** output arguments). Please don't abuse the bug tracking system for
usage questions.
You may want to consider using either .Call (if you are familiar with R) or Rcpp
(if you are more familiar with C++), .C is not the right tool here.
Cheers,
Simon
On Oct 4, 2011, at 5:49 PM, Adrin wrote:
> Hi there,
>
> I think I'm encountering a bug, and I already reported it here:
> https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14695
>
> 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,
> Adrin.
>
> 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
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>