Skip to content
Prev 350369 / 398506 Next

some general advice sought on the use of gctorture()

On 04/24/2015 06:49 AM, Franckx Laurent wrote:
segfaults often involve invalid memory access at the C level that are best 
discovered via valgrind or similar rather than gctorture. A good way to spot 
these is to

(a) come up with a _minimal_ reproducible script test.R that takes just a few 
seconds to run and that tickles, at least some times, the segfault

(b) make sure that your package is compiled without optimizations and with 
debugging symbols, e.g., in  ~/.R/Makevars add the lines

   CFLAGS="-ggdb -O0"
   CXXFLAGS="-ggdb -O0"

(c) run the code under 'valgrind'

   R -d valgrind -f test.r

Look especially for 'invalid read' or 'invalid write' messages, and isolate 
_your_ code in the callback that the message produces.

There is a 'worked example' at

   http://bioconductor.org/developers/how-to/c-debugging/#case-study

Of course this might lead to nothing, and then you'll be back to your original 
question about using gctorture or other strategies.

Martin Morgan