(gdb) where
#0 rb_vm_bugreport () at vm_dump.c:738
#1 0x00007ff4f279de2c in report_bug (file=<optimized out>, line=<optimized out>, fmt=0x7ff4f27cfce7 "Segmentation fault at %p", args=0x7ff4f4afd998) at error.c:312
#2 0x00007ff4f279f747 in rb_bug (fmt=0x7ff4f27cfce7 "Segmentation fault at %p") at error.c:339
#3 0x00007ff4f26c0057 in sigsegv (sig=<optimized out>, info=<optimized out>, ctx=<optimized out>) at signal.c:812
#4 <signal handler called>
#5 0x00007ff4f274eee6 in cont_free (ptr=0x7ff4f96fd200) at cont.c:244
#6 0x00007ff4f261af6a in obj_free (obj=140690513703000, objspace=0x7ff4f4aee000) at gc.c:1619
#7 gc_page_sweep (sweep_page=0x7ff50c621100, heap=0x7ff4f4aee010, objspace=0x7ff4f4aee000) at gc.c:2787
#8 gc_heap_lazy_sweep (objspace=0x7ff4f4aee000, heap=0x7ff4f4aee010) at gc.c:3058
#9 0x00007ff4f261b4e3 in gc_heap_rest_sweep (heap=0x7ff4f4aee010, objspace=0x7ff4f4aee000) at gc.c:3083
#10 gc_rest_sweep (objspace=0x7ff4f4aee000) at gc.c:3093
#11 rb_objspace_free (objspace=0x7ff4f4aee000) at gc.c:923
#12 0x00007ff4f273be71 in ruby_vm_destruct (vm=0x7ff4f4af4000) at vm.c:1840
#13 0x00007ff4f26018d7 in ruby_cleanup (ex=0) at eval.c:236
#14 0x00007ff4f2601c0d in ruby_run_node (n=<optimized out>) at eval.c:310
#15 0x00007ff4f25fe35b in main (argc=12, argv=0x7fff35737458) at main.c:36
(gdb) frame 5
#5 0x00007ff4f274eee6 in cont_free (ptr=0x7ff4f96fd200) at cont.c:244
244 if (GET_THREAD()->fiber != cont->self) {
There are also some other threads present in this app at shutdown time, created by a c-extension as worker threads. These threads do not interact with the ruby vm directly, but instead communicate over a queue. I guess this must be related to the segfault, but I'm not sure why it would cause ruby_current_thread to be NULL.
(gdb) info threads
Id Target Id Frame
5 Thread 0x7ff4d8f02700 (LWP 10720) 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
4 Thread 0x7ff4d9703700 (LWP 10719) 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
3 Thread 0x7ff4d9f04700 (LWP 10718) 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
2 Thread 0x7ff4ea437700 (LWP 10717) 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
* 1 Thread 0x7ff4f25c2740 (LWP 10051) rb_vm_bugreport () at vm_dump.c:738
(gdb) thread 5
[Switching to thread 5 (Thread 0x7ff4d8f02700 (LWP 10720))]
#0 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
(gdb) bt
#0 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00007ff4f0cfab7c in std::condition_variable::wait(std::unique_lock<std::mutex>&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00007ff4e217f798 in pop (item=..., this=0x7ff4e241eb80) at src/queue.hpp:29
#3 highlight_thread (thread_n=<optimized out>, theme=..., new_jobs=0x7ff4e241eb80, completed_jobs=0x7ff4e241ec40) at src/c.cpp:107
#4 0x00007ff4f0cfac78 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ff4f1eaee9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#6 0x00007ff4f129b2ed in clone () from /lib/x86_64-linux-gnu/libc.so.6
#7 0x0000000000000000 in ?? ()
(gdb) thread 4
[Switching to thread 4 (Thread 0x7ff4d9703700 (LWP 10719))]
#0 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
(gdb) where
#0 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00007ff4f0cfab7c in std::condition_variable::wait(std::unique_lock<std::mutex>&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00007ff4e217f798 in pop (item=..., this=0x7ff4e241eb80) at src/queue.hpp:29
#3 highlight_thread (thread_n=<optimized out>, theme=..., new_jobs=0x7ff4e241eb80, completed_jobs=0x7ff4e241ec40) at src/c.cpp:107
#4 0x00007ff4f0cfac78 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ff4f1eaee9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#6 0x00007ff4f129b2ed in clone () from /lib/x86_64-linux-gnu/libc.so.6
#7 0x0000000000000000 in ?? ()
(gdb) thread 3
[Switching to thread 3 (Thread 0x7ff4d9f04700 (LWP 10718))]
#0 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
(gdb) where
#0 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00007ff4f0cfab7c in std::condition_variable::wait(std::unique_lock<std::mutex>&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00007ff4e217f798 in pop (item=..., this=0x7ff4e241eb80) at src/queue.hpp:29
#3 highlight_thread (thread_n=<optimized out>, theme=..., new_jobs=0x7ff4e241eb80, completed_jobs=0x7ff4e241ec40) at src/c.cpp:107
#4 0x00007ff4f0cfac78 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ff4f1eaee9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#6 0x00007ff4f129b2ed in clone () from /lib/x86_64-linux-gnu/libc.so.6
#7 0x0000000000000000 in ?? ()
(gdb) thread 2
[Switching to thread 2 (Thread 0x7ff4ea437700 (LWP 10717))]
#0 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
(gdb) where
#0 0x00007ff4f1eb2d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00007ff4f0cfab7c in std::condition_variable::wait(std::unique_lock<std::mutex>&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00007ff4e217f798 in pop (item=..., this=0x7ff4e241eb80) at src/queue.hpp:29
#3 highlight_thread (thread_n=<optimized out>, theme=..., new_jobs=0x7ff4e241eb80, completed_jobs=0x7ff4e241ec40) at src/c.cpp:107
#4 0x00007ff4f0cfac78 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ff4f1eaee9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#6 0x00007ff4f129b2ed in clone () from /lib/x86_64-linux-gnu/libc.so.6
#7 0x0000000000000000 in ?? ()
gc.c: ensure GC state is consistent during VM shutdown
gc.c (rb_objspace_free): cause rb_bug if lazy sweep is in progress
during rb_objspace_free. Adds extra protection for r46340.
Patch by Vicent Marti. [Bug #10768] [ruby-core:67734]
gc.c (rb_objspace_call_finalizer): Ensure GC is completed after
finalizers have run. We already call gc_rest() before invoking
finalizers, but finalizer can allocate new objects and start new GC
cycle, so we call gc_rest() again after finalizers are complete.
r49474 (gc.c: ensure GC state is consistent during VM shutdown)
introduces a failure for me in test/ruby/test_io.rb.
Reverting this commit solves the problem for me on one of my
x86-64 (Debian 7.0) systems (could not reproduce the issue on
32-bit x86 nor some of my other, similar systems)
Error:
TestIO#test_io_select_with_many_files:
ArgumentError: invalid byte sequence in UTF-8
/home/ew/ruby/test/lib/envutil.rb:308:in gsub' /home/ew/ruby/test/lib/envutil.rb:308:in block (2 levels) in module:Assertions'
This is because bugreporter spew is dumping junk, so
I dumped the output via:
--- a/test/lib/envutil.rb
+++ b/test/lib/envutil.rb
@@ -286,6 +286,7 @@ module Test
FailDesc = proc do |status, message = "", out = ""|
pid = status.pid
now = Time.now
$stderr.write "#{out}\n"
faildesc = proc do
if signo = status.termsig
signame = Signal.signame(signo)
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
* gc.c (rb_objspace_free): cause rb_bug if lazy sweep is in progress
during rb_objspace_free. Adds extra protection for r46340.
Patch by Vicent Marti. [Bug #10768] [ruby-core:67734]
* gc.c (rb_objspace_call_finalizer): Ensure GC is completed after
finalizers have run. We already call gc_rest() before invoking
finalizers, but finalizer can allocate new objects and start new GC
cycle, so we call gc_rest() again after finalizers are complete.
* gc.c (rb_objspace_call_finalizer): control GC execution during
force firnalizations at the end of interpreter process.
[Bug #10768]
1) Prohibit incremental GC while running Ruby-level finalizers
to avoid any danger.
2) Prohibit GC while invoking T_DATA/T_FILE data structure
because these operations break object relations consistency.
This patch can introduce another memory consuming issue because
Ruby-level finalizers can run after (2), GC is disabled.
However, basically object consistency was broken at (2) as I
described above. So that running Ruby-level finalizers contains
danger originally. Because of this point, I need to suggest to
remove these 3 lines (invoking remaining finalizers). And add a
rule to add that finalizers should not add new finalizers, or
say there is no guarantee to invoke finalizers that added by
another finalizer.