Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R-devel with sanitizer from rocker

I'm trying to install R devel with ASAN USBAN from rocker. Following the README I tried:

sudo docker run --rm -ti rocker/r-devel-san

This took a long time to download but at the end it was ok. Then I installed the sanitizers package to test R against known errors.

install.package("sanitizers")

And I tried to get an error

> sanitizers::stackAddressSanitize(42)
[1] 24
> sanitizers::heapAddressSanitize(1)
[1] 0

I didn't get any error so I guess that the R version I'm running with docker is not built with sanitizer support. Or I simply missed something somewhere. It is my first time with docker.

like image 799
JRR Avatar asked Jan 21 '20 23:01

JRR


1 Answers

Make sure you start RD and not R. Then it works for me as expected:

> install.packages("sanitizers")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'http://cloud.r-project.org/src/contrib/sanitizers_0.1.0.tar.gz'
Content type 'application/x-gzip' length 3963 bytes
==================================================
downloaded 3963 bytes

* installing *source* package ‘sanitizers’ ...
** package ‘sanitizers’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -fsanitize=undefined,bounds-strict -fno-omit-frame-pointer -std=gnu++98 -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -Wall -pedantic -mtune=native  -c heap_address.cpp -o heap_address.o
g++ -fsanitize=undefined,bounds-strict -fno-omit-frame-pointer -std=gnu++98 -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -Wall -pedantic -mtune=native  -c stack_address.cpp -o stack_address.o
g++ -fsanitize=undefined,bounds-strict -fno-omit-frame-pointer -std=gnu++98 -shared -L/usr/local/lib/R/lib -L/usr/local/lib -o sanitizers.so heap_address.o stack_address.o -L/usr/local/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/00LOCK-sanitizers/00new/sanitizers/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (sanitizers)

The downloaded source packages are in
        ‘/tmp/RtmpqpZ0Zg/downloaded_packages’
> sanitizers::stackAddressSanitize(42)
stack_address.cpp:16:32: runtime error: index 142 out of bounds for type 'int [100]'
stack_address.cpp:16:11: runtime error: load of address 0x7fff11a2da88 with insufficient space for an object of type 'int'
0x7fff11a2da88: note: pointer points here
 ff 7f 00 00  00 00 00 00 00 00 00 00  b0 a1 85 ce d0 55 00 00  e3 b1 cb da ed 7f 00 00  78 88 fa cf
              ^ 
[1] 0
> 

In short, just as in the r-devel containers the non-vanilla version you want is RD and not R which is a plain vanilla R from the standard binary package.

like image 165
Dirk Eddelbuettel Avatar answered Oct 05 '22 23:10

Dirk Eddelbuettel