There is a (by now classic) video from the Bioconductor team describing a complete debug session of compiled R package code -- I highly recommend it.
As an aside I disagree with the previous answer and its 'Fedora recommended'. Any Linux distribution with the tools will do, they all work nicely in Docker too (and we have Rocker as well). I have worked for maybe 25 years with R and never used Fedora. The R manuals are generally also pretty clear about not recommending any one distribution, and R Core tests on several. The exact wording in Section 4.3.2 "Using valgrind" in the Writing R Extensions manual is
If you have access to Linux on a common CPU type or supported versions
of macOS or Solaris you can use 'valgrind' (https://www.valgrind.org/,
pronounced to rhyme with 'tinned') to check for possible problems. )
and I concur with that recommendation of 'any system'. Windows too can run gdb
.
To use valgrind
, instrumentation is helpful but not required. So the simplest case (to me) is still docker run --rm -ti r-base bash
to open a bash
shell in a Docker container with R (under Debian) where one could then install valgrind. That still requires understanding of Linux, and Docker, so it is not a given.
So back to the basic question: gdb
as well as print
statements can go a long in narrowing the issue down. First step, as always, is to reliably reproduce the issue.