Ask Your Question

Manually compiled R segfaults

asked 2012-03-13 11:24:05 -0500

liori gravatar image

updated 2012-03-14 10:28:12 -0500


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 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/
#5  0x00007ffff7939d5f in Rf_warning () from /home/liori/sage/sage-4.8/spkg/build/r-2 ...
edit retag flag offensive close merge delete


Hi! We definitely would need more information about your system and so forth. Do you have an abnormally small amount of memory available?

kcrisman gravatar imagekcrisman ( 2012-03-14 02:54:23 -0500 )edit

@kcrisman: updated. However even when launching R by itself I get a crash, and it shouldn't require much memory for itself.

liori gravatar imageliori ( 2012-03-14 05:04:02 -0500 )edit

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 gravatar imagekcrisman ( 2012-03-15 02:42:50 -0500 )edit

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

liori gravatar imageliori ( 2012-03-15 05:17:20 -0500 )edit

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.

kcrisman gravatar imagekcrisman ( 2012-03-15 17:28:51 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2012-03-23 03:51:59 -0500

liori gravatar image

So, it seems it is a compiler bug. Compiling on gcc 4.6 went fine with my default flags.

edit flag offensive delete link more


Great! I wonder if you can accept your own answer... might as well try it!

kcrisman gravatar imagekcrisman ( 2012-03-23 04:17:50 -0500 )edit

@kcrisman: it tells me that I need at least 50 points of reputation to do that.

liori gravatar imageliori ( 2012-03-23 05:30:27 -0500 )edit

Interesting. Hopefully you'll answer some questions (or ask good ones) over time and be able to :) At any rate, you contributed much more to this solution than I did :)

kcrisman gravatar imagekcrisman ( 2012-03-23 08:47:54 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-03-13 11:24:05 -0500

Seen: 419 times

Last updated: Mar 23 '12