Skip to content

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

5 messages · Serge, Uwe Ligges, Ivan Krylov

#
Hello,

I'm the maintener of the rtkore package and I'm experimenting an error during the installation on 
the |r-devel-windows-x86_64| and the |r-release-windows-x86_64| platform. When trying to compile I get

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

A search indicate that the problem is from the "D:" (not sure it is the correct answer)

In all case, I cannot modify these path as there given by the CRAN mechanism of compilation.

Can you give me some hints about the problem and how to solve it ?

Thanks
#
On 07.12.2023 19:29, Serge wrote:
Well, the missing d: or /d/ in the last line of your cited output.
Which package is this? Then I could take a look into the sources.

Best,
Uwe Ligges
#
https://cran.r-project.org/web/packages/rtkore/


and the Makevars in ./src/? is

#------------------------------------------------------------------------
#?? Copyright (C) 2014-2015? Serge Iovleff, University Lille1, Inria
#
#?? This program is free software: you can redistribute it and/or modify
#?? it under the terms of the GNU General Public License as published by
#?? the Free Software Foundation, either version 3 of the License, or
#?? (at your option) any later version.
#
#?? This program is distributed in the hope that it will be useful,
#?? but WITHOUT ANY WARRANTY; without even the implied warranty of
#?? MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.? See the
#?? GNU General Public License for more details.
#
#?? You should have received a copy of the GNU General Public License
#?? along with this program.? If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------
#?? Project:??? rtkore
#?? Created on: Feb 17, 2014
#?? Authors:??? Serge IOVLEFF <serge_DOT_iov..._AT_stkpp_DOT_org>
#-----------------------------------------------------------------------
## define PKG_CPPFLAGS (preprocessor & includes) and PKG_CXXFLAGS (compiler flags)
CXX_STD = CXX11

PKG_CXXFLAGS = -I'../inst/projects/' -I'../inst/include/' -DIS_RTKPP_LIB? -DSTKUSELAPACK 
$(SHLIB_OPENMP_CXXFLAGS)
#PKG_CXXFLAGS =
PKG_LIBS???? = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CXXFLAGS)

## And export
export

## $(SHLIB) is the usual default target that is built automatically from all source
## files in this directory. pkglib is an additional target for the library
## that will be installed in inst/ and which users can link against.
.PHONY: all

all: $(SHLIB)

Le 08/12/2023 ? 11:12, Uwe Ligges a ?crit?:

  
  
6 days later
#
It looks like the problem was coming from this line in the Makevars

## $(SHLIB) is the usual default target that is built automatically from all source
## files in this directory. pkglib is an additional target for the library
## that will be installed in inst/ and which users can link against.
.PHONY: all

all: $(SHLIB)

Don't remember why I had these lines in the Makevars, the first release of the package is from 2015.
A quick check on other packages on CRAN shows than it is (no more ?) not necessary.

Serge


Le 08/12/2023 ? 12:24, Serge a ?crit?:

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

            
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