Manually compiled R segfaults
Hello,
My R crashes when I try to compile it manually. This is the output of make
when trying to compile sagemath
from scratch:
gcc -std=gnu99 -I../../../../include -I../../../include -I../../../../src/include -DHAVE_CONFIG_H -I/home/liori/sage/sage-4.8/l
e -L/home/liori/sage/sage-4.8/local/lib/ -march=nocona -O2 -fomit-frame-pointer -s -pipe -c md5.c -o md5.o
gcc -std=gnu99 -I../../../../include -I../../../include -I../../../../src/include -DHAVE_CONFIG_H -I/home/liori/sage/sage-4.8/l
e -L/home/liori/sage/sage-4.8/local/lib/ -march=nocona -O2 -fomit-frame-pointer -s -pipe -c signals.c -o signals.o
gcc -std=gnu99 -shared -L/home/liori/sage/sage-4.8/local/lib/ -o tools.so text.o init.o Rmd5.o md5.o signals.o -L../../../../li
make[8]: Entering directory `/home/liori/sage/sage-4.8/spkg/build/r-2.14.0.p1/src/src/library/tools/src'
make[8]: `Makedeps' is up to date.
make[8]: Leaving directory `/home/liori/sage/sage-4.8/spkg/build/r-2.14.0.p1/src/src/library/tools/src'
make[8]: Entering directory `/home/liori/sage/sage-4.8/spkg/build/r-2.14.0.p1/src/src/library/tools/src'
mkdir -p -- ../../../../library/tools/libs
make[8]: Leaving directory `/home/liori/sage/sage-4.8/spkg/build/r-2.14.0.p1/src/src/library/tools/src'
make[7]: Leaving directory `/home/liori/sage/sage-4.8/spkg/build/r-2.14.0.p1/src/src/library/tools/src'
make[6]: Leaving directory `/home/liori/sage/sage-4.8/spkg/build/r-2.14.0.p1/src/src/library/tools'
*** caught segfault ***
address 0x7fff17a1f090, cause 'memory not mapped'
aborting ...
/bin/bash: line 1: 9951 Done echo "tools:::.install_package_description('.', '"../../../library/tools"')"
9952 Segmentation fault | R_DEFAULT_PACKAGES=NULL ../../../bin/R --vanilla --slave > /dev/null
Same thing when I tried to use a binary sagemath
distribution and just recompile R there using ./sage -f r
. When R is run as standalone binary, it crashes right after printing invitation text. I launched it with .../R --debugger gdb
and printed backtrace:
[...]
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Program received signal SIGSEGV, Segmentation fault.
strchrnul () at ../sysdeps/x86_64/strchrnul.S:34
34 ../sysdeps/x86_64/strchrnul.S: No such file or directory.
in ../sysdeps/x86_64/strchrnul.S
Current language: auto
The current source language is "auto; currently asm".
(gdb) bt
#0 strchrnul () at ../sysdeps/x86_64/strchrnul.S:34
#1 0x00007ffff712cd2f in __find_specmb (s=0x7fffffff9a00, format=0x7ffffffff028 <Address 0x7ffffffff028 out of bounds>,
ap=0x7fffffffbb80) at printf-parse.h:99
#2 _IO_vfprintf_internal (s=0x7fffffff9a00, format=0x7ffffffff028 <Address 0x7ffffffff028 out of bounds>, ap=0x7fffffffbb80)
at vfprintf.c:1325
#3 0x00007ffff71524f2 in _IO_vsnprintf (string=0x7fffffff9b80 "", maxlen=<value optimized out>,
format=0x7ffffffff028 <Address 0x7ffffffff028 out of bounds>, args=0x7fffffffbb80) at vsnprintf.c:120
#4 0x00007ffff793671b in Rvsnprintf () from /home/liori/sage/sage-4.8/spkg/build/r-2.14.0.p1/src/lib/libR.so
#5 0x00007ffff7939d5f in Rf_warning () from /home/liori/sage/sage-4.8/spkg/build/r-2 ...
Hi! We definitely would need more information about your system and so forth. Do you have an abnormally small amount of memory available?
@kcrisman: updated. However even when launching R by itself I get a crash, and it shouldn't require much memory for itself.
Thanks. Hopefully someone who understands how the flags do things will know what the problem was. In general Sage tries to already include good flags for compilation (since most Sage users know even less than I do about them), so I'm not at all surprised that this caused a problem. Maybe R can't handle the optimization on your computer?
@kcrisman: i started bisecting the flags yesterday only to find that there's another compilation error (compiler reports bug in its own code) that shows on gcc 4.4 (which is installed on that VPS), but not on 4.5. I might find some time during the weekend to check it, but it's not a big priority to me now... I'll probably try getting gcc 4.7 on that VPS and recompile everything just to be sure. For now I use R compiled with `-O0` and it is good enough for my purposes.
Well! Glad it worked out. What happens if you compile R with those flags from its source distribution? Maybe it just can't be optimized that much on that platform, we've seen this problem with other upstream packages in Sage.