我正在尝试从rocker将R devel与ASAN USBAN一起安装。按照自述文件我尝试过:

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版本未构建有 sanitizer 支持。或者我只是在某处错过了一些东西。这是我第一次使用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,它是标准二进制软件包中的普通 Vanilla R。

关于R-devel与翘板 sanitizer ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59850638/

10-12 17:12