The Writing R Extensions manual details in Section 4.3 how to check memory access. Two sections are devoted to Using the Address Sanitizer and to Using the Undefined Behaviour Sanitizer.
Both require a particularly instrumented binary of R. This repository provides a Docker container with such a binary, based on the R-devel sources.
This repository uses gcc; a sibling repository uses clang.
Note that the instrumented version of R
is available on the path as Rdevel
, symbolically linked
as RD
, and that the instrumented versions of Rscript
is Rscriptdevel
with symbolic link
RDscript
. Based on the R-devel sources, they use the sanitizer setup that is the focuse here
whereas the R
and Rscript
binaries come from the standard binary package and correspond to
R-release without any sanitizer instrumentation. So use RD
and RDscript
to inspect undefined
behavior.
The sanitiziers package by
Dirk (also on CRAN
here) contains 'known bad' behavior
detected by sanitizers, It can be used to validate the setup as it should detect the errors under
RD
and RDscript
---but not under R
and Rscript
which are not instrumented. If in doubt, use
this to familiarise yourself with the sanitizer behavior.
The (newer, larger) r-debug by Winston is also available with even more build configs and is also recommended.
This repository is part of Rocker-Org where Rocker -- Docker containers of interest for R users -- is being developed.
All this is work in progress; talk to Dirk or Carl about how to get involved.
Documentation is being added at the Rocker Wiki.