R-devel 与摇杆消毒剂

R-devel with sanitizer from rocker

我正在尝试使用来自 rocker 的 ASAN USBAN 安装 R devel。按照我尝试的自述文件:

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

这个下载的时间比较长,不过最后还是可以的。然后我安装了 sanitizers 包以针对已知错误测试 R。

install.package("sanitizers")

然后我尝试得到一个错误

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

我没有收到任何错误,所以我猜我 运行 docker 的 R 版本不支持消毒剂。或者我只是错过了某处的东西。这是我第一次 docker.

确保你开始 RD 而不是 R。然后它按预期对我有用:

> 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
> 

简而言之,就像在 r-devel 容器中一样,您想要的非香草版本是 RD 而不是 R,后者是标准二进制包中的普通香草 R。