Skip to content

Commit

Permalink
Updates to README and Dockerfile following sibbling repo
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Jan 7, 2025
1 parent 15b76b1 commit 7e98259
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 21 deletions.
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ LABEL org.label-schema.license="GPL-2.0" \
maintainer="Dirk Eddelbuettel <[email protected]>"

## Remain current
RUN apt-get update -qq \
&& apt-get dist-upgrade -y
RUN apt update -qq \
&& apt dist-upgrade -y

## From the Build-Depends of the Debian R package, plus subversion, and clang-3.8
## Compiler flags from https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt
##
## Also add git autotools-dev automake so that we can build littler from source
## libclang-rt-16-dev now required
##
RUN apt-get update -qq \
&& apt-get install -t unstable -y --no-install-recommends \
RUN apt update -qq \
&& apt install -t unstable -y --no-install-recommends \
automake \
autotools-dev \
bash-completion \
Expand Down Expand Up @@ -134,5 +134,7 @@ RUN cd /usr/local/bin \
&& ln -s Rscriptdevel RDscript

## Install littler
RUN ASAN_OPTIONS=detect_leaks=0 R --slave -e "install.packages('littler')" \
&& ASAN_OPTIONS=detect_leaks=0 RD --slave -e "install.packages('littler')"
RUN ASAN_OPTIONS='detect_leaks=0' R --slave -e "install.packages('littler')" \
&& ASAN_OPTIONS='detect_leaks=0' RD --slave -e "install.packages('littler')"

CMD ["bash"]
51 changes: 36 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,48 @@

## R-devel SAN using Clang: R development binaries with Sanitizer support

The [Writing R Extensions manual](http://cran.r-project.org/doc/manuals/r-devel/R-exts.html)
details in [Section 4.3](http://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Checking-memory-access)
how to check memory access. Two sections are devoted to
[Using the Address Sanitizer](http://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Using-Address-Sanitizer)
and to
[Using the Undefined Behaviour Sanitizer](http://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Using-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 clang; a [sibling repository](https://github.com/rocker-org/r-devel-san) uses gcc.

**Note**: This container must be run with `docker run --cap-add SYS_PTRACE`, otherwise instrumented processes fail to start due to lacking permissions. Alternatively, an instrumented process can be run with `ASAN_OPTIONS=detect_leaks=0`, but this turns off leak detection.
The [Writing R Extensions manual](http://cran.r-project.org/doc/manuals/r-devel/R-exts.html) details
in [Section 4.3](http://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Checking-memory-access)
how to check memory access. Two sections are devoted to [Using the Address
Sanitizer](http://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Using-Address-Sanitizer) and to
[Using the Undefined Behaviour
Sanitizer](http://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Using-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 clang; a [sibling repository](https://github.com/rocker-org/r-devel-san) uses
gcc.

**Note**: At least under some Docker versions, this container must be run with `docker run --cap-add
SYS_PTRACE`, otherwise instrumented processes fail to start due to lacking
permissions. Alternatively, an instrumented process can be run with `ASAN_OPTIONS=detect_leaks=0`,
but this turns off leak detection.

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](https://github.com/eddelbuettel/sanitizers) package by
[Dirk](https://github.com/eddelbuettel) (also on CRAN
[here](https://cran.r-project.org/web/packages/sanitizers/index.html)) 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](https://github.com/wch/r-debug) by [Winston](https://github.com/wch/)
is also available with even more build configs and is also recommended.

## Rocker-Org

This repository is part of [Rocker-Org](https://github.com/rocker-org) where
[Rocker](https://github.com/rocker-org/rocker) -- Docker containers of
interest for R users -- is being developed.

All this is work in progress; talk to @eddelbuettel and @cboettig about how
to get involved.
All this is work in progress; talk to [Dirk](https://github.com/eddelbuettel) or
[Carl](https://github.com/cboettig) about how to get involved.

Documentation is being added at the [Rocker Wiki](https://github.com/rocker-org/rocker/wiki).

0 comments on commit 7e98259

Please sign in to comment.