[R-pkg-devel] Getting 'Rscript: Bad address' error when CRAN build my package on windows platforms

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Thu Dec 14 21:40:15 CET 2023


On Thu, 7 Dec 2023 19:29:46 +0100
Serge <Serge.Iovleff using stkpp.org> wrote:

> g++ -std=gnu++11 -I"D:/RCompile/recent/R-4.3.2/include" -DNDEBUG
> -I../inst/projects/ -I../inst/include/ -DIS_RTKPP_LIB -DSTKUSELAPACK
> -I'D:/RCompile/CRANpkg/lib/4.3/Rcpp/include'
> -I"d:/rtools43/x86_64-w64-mingw32.static.posix/include" -fopenmp -O2
> -Wall -mfpmath=sse -msse2 -mstackrealign -c fastRand.cpp -o
> fastRand.o
> /bin/sh: line 1: /x86_64-w64-mingw32.static.posix/bin/g++: Bad address

I don't think this is a problem with your package. The shell says "Bad
address" when it gets an EFAULT while trying to run a program:

$ strace -f -e fault=execve:error=EFAULT:when=1 -e trace=execve \
 /bin/sh -c '/usr/bin/g++'
execve("/bin/sh", ["/bin/sh", "-c", "/usr/bin/g++"], [/* 51 vars */]) = 0
strace: Process 20756 attached
[pid 20756] execve("/usr/bin/g++", ["/usr/bin/g++"], [/* 50 vars */]) = -1 EFAULT (Bad address) (INJECTED)
/bin/sh: 1: /usr/bin/g++: Bad address

There is not enough information to find out why this happens. I think
that since Rtools are based on MSYS2 which is based on Cygwin, the
place to look for EFAULT is Cygwin's implementation of the exec()
system call. Indeed, there's one such place there, after the giant
structured exception handling __try block, where errno is set to EFAULT
if the system got such an exception while launching a process without
previously setting errno to ENOMEM:
https://cygwin.com/cgit/newlib-cygwin/tree/winsup/cygwin/spawn.cc?id=ca2a4ec243627b19f0ac2c7262703f81712f3be4#n947

Does this happen every time? If not, I think the problem was
Win-Builder temporary running out of memory.

P.S.: Please don't compose HTML e-mail to this list with Thunderbird.
Thunderbird's auto-generated plain text version is all we get, and it's
severely mangled:
https://stat.ethz.ch/pipermail/r-package-devel/2023q4/010178.html

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list