Issue
I'm getting crazy here. I am just trying to deploy a little test application on my server, and I keep getting a segmentation fault whenever the Ruby interpreter quits (i.e., after running rake assets:precompile
, or quitting the console, etc). Just running
script/rails r -e production "puts 1"
will lead to
1
[BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
-- C level backtrace information -------------------------------------------
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9 [0x7f92fd681f25]
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9 [0x7f92fd55608c]
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(rb_bug+0xb8) [0x7f92fd556208] error.c:277
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9 [0x7f92fd60db77]
/lib/libpthread.so.0 [0x7f92fd2e5a80]
/lib/libselinux.so.1 [0x7f92f0db831d]
/lib/libselinux.so.1 [0x7f92f0dab57f]
-- Other runtime information -----------------------------------------------
Segmentation fault
Note that the scripts/Rake tasks, whatever do run, but on exit → segmentation fault.
The weird thing is, this 1. happens only on my server (Debian 5.0 (Lenny), rvm, Ruby 1.9.2 or 1.9.3) and only in production mode.
So naturally I thought: some production group gem is causing this, and I tried switching off the production group in my Gemfile, as well as switching production <-> development gems. No change; every time Ruby quits → segmentation fault.
What can I do? What are some debugging tips to get to the root of this? The backtrace for this segmentation fault leaves me without absolutely any hint.
(I tried removing Ruby, and recompiling, and I tried 1.9.2-p290 and 1.9.3, but the same result.)
Okay, backtrace time:
#0 rb_string_value (ptr=0x5a8) at string.c:1406
1406 VALUE s = *ptr;
(gdb) where
#0 rb_string_value (ptr=0x5a8) at string.c:1406
#1 0x00007f3c5b619428 in rb_string_value_cstr (ptr=0x5a8) at string.c:1424
#2 0x00007f3c5b6708cc in rb_vm_bugreport () at vm_dump.c:826
#3 0x00007f3c5b549f1c in report_bug (file=<value optimized out>, line=<value optimized out>, fmt=0x7f3c5b69e88b "Segmentation fault", args=0x66cd40) at error.c:258
#4 0x00007f3c5b54a098 in rb_bug (fmt=0x7f3c5b69e88b "Segmentation fault") at error.c:277
#5 0x00007f3c5b5fe037 in sigsegv (sig=<value optimized out>, info=<value optimized out>, ctx=<value optimized out>) at signal.c:609
#6 <signal handler called>
#7 0x00007f3c4e6fa18d in fini_context_translations () at setrans_client.c:211
#8 0x00007f3c4e6ed5df in __do_global_dtors_aux () from /lib/libselinux.so.1
#9 0x0000000000400850 in setlocale@plt ()
#10 0x00007fffffffdec0 in ?? ()
#11 0x00007f3c4e6fb991 in _fini () from /lib/libselinux.so.1
#12 0x000000000000005f in ?? ()
#13 0x00007f3c5b933d94 in ?? () from /lib64/ld-linux-x86-64.so.2
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Solution
Okay, I got it!
It's actually bug #505920 - python-clutter: ends with segmentation fault in libselinux, which has been fixed a while ago, but the updates didn't make it into Debian 5.0 (Lenny)(?).
I took the liberty and installed the libselinux1 deb from Debian 6.0 (Squeeze). I'm not sure if this is actually a good idea, but at least the problem is gone.
Answered By - Marian Theisen