Bug #9212

Segmentation fault in test/objspace/test_objspace.rb#test_dump_all

Added by Alexey Borzenkov over 1 year ago. Updated over 1 year ago.

[ruby-core:58853]
Status:Closed
Priority:Normal
Assignee:Aman Gupta
ruby -v:ruby 2.1.0dev (2013-12-04 trunk 43989) [x86_64-linux] Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN

Description

At least on Linux x64 (Ubuntu 3.10) the test_dump_all test occasionally fails with:

TypeError: no implicit conversion of nil into String.

When I inspected output and error I found that it actually fails with this error:

/home/{username}/mirrors/trunk-git/lib/rubygems/core_ext/kernel_require.rb:55: [BUG] Segmentation fault at 0x00000000000000
ruby 2.1.0dev (2013-12-04 trunk 43989) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0010 p:---- s:0045 e:000044 CFUNC :require
c:0009 p:0115 s:0041 e:000040 METHOD /home/{username}/mirrors/trunk-git/lib/rubygems/core_ext/kernel_require.rb:55
c:0008 p:0007 s:0031 e:000030 TOP /home/{username}/mirrors/trunk-git/lib/tmpdir.rb:7 [FINISH]
c:0007 p:---- s:0029 e:000028 CFUNC :require
c:0006 p:0115 s:0025 e:000024 METHOD /home/{username}/mirrors/trunk-git/lib/rubygems/core_ext/kernel_require.rb:55
c:0005 p:0015 s:0015 e:000014 TOP /home/{username}/mirrors/trunk-git/lib/tempfile.rb:8 [FINISH]
c:0004 p:---- s:0012 e:000011 CFUNC :dump_all
c:0003 p:0047 s:0009 e:000008 METHOD -:5
c:0002 p:0019 s:0005 E:001f58 EVAL -:8 [FINISH]
c:0001 p:0000 s:0002 E:002048 TOP [FINISH]

-- Ruby level backtrace information ----------------------------------------
-:8:in <main>'
-:5:in
dump_my_heap_please'
-:5:in dump_all'
/home/{username}/mirrors/trunk-git/lib/tempfile.rb:8:in
'
/home/{username}/mirrors/trunk-git/lib/rubygems/core_ext/kernel_require.rb:55:in require'
/home/{username}/mirrors/trunk-git/lib/rubygems/core_ext/kernel_require.rb:55:in
require'
/home/{username}/mirrors/trunk-git/lib/tmpdir.rb:7:in <top (required)>'
/home/{username}/mirrors/trunk-git/lib/rubygems/core_ext/kernel_require.rb:55:in
require'
/home/{username}/mirrors/trunk-git/lib/rubygems/core_ext/kernel_require.rb:55:in `require'

-- C level backtrace information -------------------------------------------
/home/{username}/build/ruby/ruby(+0x1852ec) [0x2b1ca09fa2ec]
/home/{username}/build/ruby/ruby(+0x1f70b3) [0x2b1ca0a6c0b3]
/home/{username}/build/ruby/ruby(rb_bug+0xb3) [0x2b1ca0a6d293]
/home/{username}/build/ruby/ruby(+0xf9cfe) [0x2b1ca096ecfe]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xfbb0) [0x2b1ca0f96bb0] ../nptl/sysdeps/pthread/funlockfile.c:29
/home/{username}/build/ruby/ruby(+0x3e563) [0x2b1ca08b3563]
/home/{username}/build/ruby/ruby(+0x3f4a8) [0x2b1ca08b44a8]
/home/{username}/build/ruby/ruby(+0x4278f) [0x2b1ca08b778f]
/home/{username}/build/ruby/ruby(+0x43a49) [0x2b1ca08b8a49]
/home/{username}/build/ruby/ruby(rb_newobj_of+0x119) [0x2b1ca08b8fd9]
/home/{username}/build/ruby/ruby(rb_str_dup+0x1b) [0x2b1ca098600b]
/home/{username}/build/ruby/ruby(rb_class_path+0x83) [0x2b1ca09be963]
/home/{username}/build/ruby/.ext/x86_64-linux/objspace.so(+0x3490) [0x2b1ca22bb490] ../../../../mirrors/trunk-git/ext/objspace/object_tracing.c:84
/home/{username}/build/ruby/ruby(+0x188b99) [0x2b1ca09fdb99]
/home/{username}/build/ruby/ruby(+0x18ba0f) [0x2b1ca0a00a0f]
/home/{username}/build/ruby/ruby(+0x20c1a) [0x2b1ca0895c1a]
/home/{username}/build/ruby/ruby(rb_node_newnode+0xf3) [0x2b1ca08b8e03]
/home/{username}/build/ruby/ruby(+0xa4791) [0x2b1ca0919791]
/home/{username}/build/ruby/ruby(+0xa6407) [0x2b1ca091b407]
/home/{username}/build/ruby/ruby(+0x18bc61) [0x2b1ca0a00c61]
/home/{username}/build/ruby/ruby(rb_parser_compile_file_path+0xa8) [0x2b1ca09065c8]
/home/{username}/build/ruby/ruby(+0xf799d) [0x2b1ca096c99d]
/home/{username}/build/ruby/ruby(rb_ensure+0x117) [0x2b1ca089bcc7]
/home/{username}/build/ruby/ruby(rb_load_file_str+0xda) [0x2b1ca096e1ba]
/home/{username}/build/ruby/ruby(+0x1fda5b) [0x2b1ca0a72a5b]
/home/{username}/build/ruby/ruby(rb_require_safe+0x57e) [0x2b1ca0a743de]
/home/{username}/build/ruby/ruby(+0x16e414) [0x2b1ca09e3414]
/home/{username}/build/ruby/ruby(+0x17319c) [0x2b1ca09e819c]
/home/{username}/build/ruby/ruby(+0x176cbc) [0x2b1ca09ebcbc]
/home/{username}/build/ruby/ruby(rb_iseq_eval+0x1aa) [0x2b1ca09f7e3a]
/home/{username}/build/ruby/ruby(+0x1fdab0) [0x2b1ca0a72ab0]
/home/{username}/build/ruby/ruby(rb_require_safe+0x57e) [0x2b1ca0a743de]
/home/{username}/build/ruby/ruby(+0x16e414) [0x2b1ca09e3414]
/home/{username}/build/ruby/ruby(+0x17b76e) [0x2b1ca09f076e]
/home/{username}/build/ruby/ruby(+0x17319c) [0x2b1ca09e819c]
/home/{username}/build/ruby/ruby(+0x176cbc) [0x2b1ca09ebcbc]
/home/{username}/build/ruby/ruby(rb_iseq_eval+0x1aa) [0x2b1ca09f7e3a]
/home/{username}/build/ruby/ruby(+0x1fdab0) [0x2b1ca0a72ab0]
/home/{username}/build/ruby/ruby(rb_require_safe+0x57e) [0x2b1ca0a743de]
/home/{username}/build/ruby/.ext/x86_64-linux/objspace.so(+0x732c) [0x2b1ca22bf32c] ../../../../mirrors/trunk-git/ext/objspace/objspace_dump.c:296
/home/{username}/build/ruby/ruby(+0x16e414) [0x2b1ca09e3414]
/home/{username}/build/ruby/ruby(+0x17b76e) [0x2b1ca09f076e]
/home/{username}/build/ruby/ruby(+0x17319c) [0x2b1ca09e819c]
/home/{username}/build/ruby/ruby(+0x176cbc) [0x2b1ca09ebcbc]
/home/{username}/build/ruby/ruby(rb_iseq_eval_main+0x1f6) [0x2b1ca09f80a6]
/home/{username}/build/ruby/ruby(+0x22b6a) [0x2b1ca0897b6a]
/home/{username}/build/ruby/ruby(ruby_run_node+0x2d) [0x2b1ca089b02d]
/home/{username}/build/ruby/ruby(+0x2277b) [0x2b1ca089777b]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x2b1ca1906de5] ../../mirrors/trunk-git/vm_insnhelper.c:151
/home/{username}/build/ruby/ruby(+0x227a9) [0x2b1ca08977a9]

-- Other runtime information -----------------------------------------------

  • Loaded script: -

  • Loaded features:

    0 enumerator.so
    1 /home/{username}/build/ruby/.ext/x86_64-linux/enc/encdb.so
    2 /home/{username}/build/ruby/.ext/x86_64-linux/enc/trans/transdb.so
    3 /home/{username}/build/ruby/rbconfig.rb
    4 /home/{username}/mirrors/trunk-git/lib/rubygems/compatibility.rb
    5 /home/{username}/mirrors/trunk-git/lib/rubygems/defaults.rb
    6 /home/{username}/mirrors/trunk-git/lib/rubygems/deprecate.rb
    7 /home/{username}/mirrors/trunk-git/lib/rubygems/errors.rb
    8 /home/{username}/mirrors/trunk-git/lib/rubygems/version.rb
    9 /home/{username}/mirrors/trunk-git/lib/rubygems/requirement.rb
    10 /home/{username}/mirrors/trunk-git/lib/rubygems/platform.rb
    11 /home/{username}/mirrors/trunk-git/lib/rubygems/basic_specification.rb
    12 /home/{username}/mirrors/trunk-git/lib/rubygems/stub_specification.rb
    13 /home/{username}/mirrors/trunk-git/lib/rubygems/util/stringio.rb
    14 /home/{username}/mirrors/trunk-git/lib/rubygems/specification.rb
    15 /home/{username}/mirrors/trunk-git/lib/rubygems/exceptions.rb
    16 /home/{username}/mirrors/trunk-git/lib/rubygems/core_ext/kernel_gem.rb
    17 thread.rb
    18 /home/{username}/build/ruby/.ext/x86_64-linux/thread.so
    19 /home/{username}/mirrors/trunk-git/lib/monitor.rb
    20 /home/{username}/mirrors/trunk-git/lib/rubygems/core_ext/kernel_require.rb
    21 /home/{username}/mirrors/trunk-git/lib/rubygems.rb
    22 /home/{username}/build/ruby/.ext/x86_64-linux/objspace.so
    23 /home/{username}/mirrors/trunk-git/lib/delegate.rb

  • Process memory map:

2b1ca0875000-2b1ca0b35000 r-xp 00000000 08:02 207071990 /home/{username}/build/ruby/ruby
2b1ca0b35000-2b1ca0b37000 rw-p 00000000 00:00 0
2b1ca0b37000-2b1ca0b38000 ---p 00000000 00:00 0
2b1ca0b38000-2b1ca0b3c000 rw-p 00000000 00:00 0
2b1ca0b4e000-2b1ca0c53000 rw-p 00000000 00:00 0
2b1ca0d35000-2b1ca0d3a000 r--p 002c0000 08:02 207071990 /home/{username}/build/ruby/ruby
2b1ca0d3a000-2b1ca0d3c000 rw-p 002c5000 08:02 207071990 /home/{username}/build/ruby/ruby
2b1ca0d3c000-2b1ca0d62000 rw-p 00000000 00:00 0
2b1ca0d62000-2b1ca0d85000 r-xp 00000000 08:02 67241836 /lib/x86_64-linux-gnu/ld-2.17.so
2b1ca0f84000-2b1ca0f85000 r--p 00022000 08:02 67241836 /lib/x86_64-linux-gnu/ld-2.17.so
2b1ca0f85000-2b1ca0f87000 rw-p 00023000 08:02 67241836 /lib/x86_64-linux-gnu/ld-2.17.so
2b1ca0f87000-2b1ca0f9e000 r-xp 00000000 08:02 67242007 /lib/x86_64-linux-gnu/libpthread-2.17.so
2b1ca0f9e000-2b1ca119e000 ---p 00017000 08:02 67242007 /lib/x86_64-linux-gnu/libpthread-2.17.so
2b1ca119e000-2b1ca119f000 r--p 00017000 08:02 67242007 /lib/x86_64-linux-gnu/libpthread-2.17.so
2b1ca119f000-2b1ca11a0000 rw-p 00018000 08:02 67242007 /lib/x86_64-linux-gnu/libpthread-2.17.so
2b1ca11a0000-2b1ca11a4000 rw-p 00000000 00:00 0
2b1ca11a4000-2b1ca11a7000 r-xp 00000000 08:02 67241875 /lib/x86_64-linux-gnu/libdl-2.17.so
2b1ca11a7000-2b1ca13a6000 ---p 00003000 08:02 67241875 /lib/x86_64-linux-gnu/libdl-2.17.so
2b1ca13a6000-2b1ca13a7000 r--p 00002000 08:02 67241875 /lib/x86_64-linux-gnu/libdl-2.17.so
2b1ca13a7000-2b1ca13a8000 rw-p 00003000 08:02 67241875 /lib/x86_64-linux-gnu/libdl-2.17.so
2b1ca13a8000-2b1ca13b2000 r-xp 00000000 08:02 67241868 /lib/x86_64-linux-gnu/libcrypt-2.17.so
2b1ca13b2000-2b1ca15b1000 ---p 0000a000 08:02 67241868 /lib/x86_64-linux-gnu/libcrypt-2.17.so
2b1ca15b1000-2b1ca15b2000 r--p 00009000 08:02 67241868 /lib/x86_64-linux-gnu/libcrypt-2.17.so
2b1ca15b2000-2b1ca15b3000 rw-p 0000a000 08:02 67241868 /lib/x86_64-linux-gnu/libcrypt-2.17.so
2b1ca15b3000-2b1ca15e1000 rw-p 00000000 00:00 0
2b1ca15e1000-2b1ca16e4000 r-xp 00000000 08:02 67241943 /lib/x86_64-linux-gnu/libm-2.17.so
2b1ca16e4000-2b1ca18e3000 ---p 00103000 08:02 67241943 /lib/x86_64-linux-gnu/libm-2.17.so
2b1ca18e3000-2b1ca18e4000 r--p 00102000 08:02 67241943 /lib/x86_64-linux-gnu/libm-2.17.so
2b1ca18e4000-2b1ca18e5000 rw-p 00103000 08:02 67241943 /lib/x86_64-linux-gnu/libm-2.17.so
2b1ca18e5000-2b1ca1aa2000 r-xp 00000000 08:02 67241860 /lib/x86_64-linux-gnu/libc-2.17.so
2b1ca1aa2000-2b1ca1ca2000 ---p 001bd000 08:02 67241860 /lib/x86_64-linux-gnu/libc-2.17.so
2b1ca1ca2000-2b1ca1ca6000 r--p 001bd000 08:02 67241860 /lib/x86_64-linux-gnu/libc-2.17.so
2b1ca1ca6000-2b1ca1ca8000 rw-p 001c1000 08:02 67241860 /lib/x86_64-linux-gnu/libc-2.17.so
2b1ca1ca8000-2b1ca1cad000 rw-p 00000000 00:00 0
2b1ca1cad000-2b1ca1caf000 r-xp 00000000 08:02 52640410 /home/{username}/build/ruby/.ext/x86_64-linux/enc/encdb.so
2b1ca1caf000-2b1ca1eae000 ---p 00002000 08:02 52640410 /home/{username}/build/ruby/.ext/x86_64-linux/enc/encdb.so
2b1ca1eae000-2b1ca1eaf000 r--p 00001000 08:02 52640410 /home/{username}/build/ruby/.ext/x86_64-linux/enc/encdb.so
2b1ca1eaf000-2b1ca1eb0000 rw-p 00002000 08:02 52640410 /home/{username}/build/ruby/.ext/x86_64-linux/enc/encdb.so
2b1ca1eb0000-2b1ca1eb2000 r-xp 00000000 08:02 135356040 /home/{username}/build/ruby/.ext/x86_64-linux/enc/trans/transdb.so
2b1ca1eb2000-2b1ca20b2000 ---p 00002000 08:02 135356040 /home/{username}/build/ruby/.ext/x86_64-linux/enc/trans/transdb.so
2b1ca20b2000-2b1ca20b3000 r--p 00002000 08:02 135356040 /home/{username}/build/ruby/.ext/x86_64-linux/enc/trans/transdb.so
2b1ca20b3000-2b1ca20b4000 rw-p 00003000 08:02 135356040 /home/{username}/build/ruby/.ext/x86_64-linux/enc/trans/transdb.so
2b1ca20b4000-2b1ca20b7000 r-xp 00000000 08:02 207741732 /home/{username}/build/ruby/.ext/x86_64-linux/thread.so
2b1ca20b7000-2b1ca22b6000 ---p 00003000 08:02 207741732 /home/{username}/build/ruby/.ext/x86_64-linux/thread.so
2b1ca22b6000-2b1ca22b7000 r--p 00002000 08:02 207741732 /home/{username}/build/ruby/.ext/x86_64-linux/thread.so
2b1ca22b7000-2b1ca22b8000 rw-p 00003000 08:02 207741732 /home/{username}/build/ruby/.ext/x86_64-linux/thread.so
2b1ca22b8000-2b1ca22c3000 r-xp 00000000 08:02 207679888 /home/{username}/build/ruby/.ext/x86_64-linux/objspace.so
2b1ca22c3000-2b1ca24c2000 ---p 0000b000 08:02 207679888 /home/{username}/build/ruby/.ext/x86_64-linux/objspace.so
2b1ca24c2000-2b1ca24c3000 r--p 0000a000 08:02 207679888 /home/{username}/build/ruby/.ext/x86_64-linux/objspace.so
2b1ca24c3000-2b1ca24c4000 rw-p 0000b000 08:02 207679888 /home/{username}/build/ruby/.ext/x86_64-linux/objspace.so
2b1ca24c4000-2b1ca24d9000 r-xp 00000000 08:02 70044656 /lib/x86_64-linux-gnu/libgcc_s.so.1
2b1ca24d9000-2b1ca26d8000 ---p 00015000 08:02 70044656 /lib/x86_64-linux-gnu/libgcc_s.so.1
2b1ca26d8000-2b1ca26d9000 r--p 00014000 08:02 70044656 /lib/x86_64-linux-gnu/libgcc_s.so.1
2b1ca26d9000-2b1ca26da000 rw-p 00015000 08:02 70044656 /lib/x86_64-linux-gnu/libgcc_s.so.1
2b1ca289e000-2b1ca2e64000 rw-p 00000000 00:00 0 [heap]
7fff87e75000-7fff87e96000 rw-p 00000000 00:00 0
7fff87f1b000-7fff87f1d000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]

[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

Associated revisions

Revision 44088
Added by Nobuyoshi Nakada over 1 year ago

object_tracing.c: fix allocation from NEWOBJ hook

  • ext/objspace/object_tracing.c (newobj_i): use cached class path only to get rid object allocation during NEWOBJ hook. [Bug #9212]

Revision 44088
Added by Nobuyoshi Nakada over 1 year ago

object_tracing.c: fix allocation from NEWOBJ hook

  • ext/objspace/object_tracing.c (newobj_i): use cached class path only to get rid object allocation during NEWOBJ hook. [Bug #9212]

History

#1 Updated by Aman Gupta over 1 year ago

ruby/ruby(rb_class_path+0x83) [0x2b1ca09be963]
ruby/.ext/x86_64-linux/objspace.so(+0x3490) [0x2b1ca22bb490] ../../../../mirrors/trunk-git/ext/objspace/object_tracing.c:84

This is a known issue in the current implementation.
We need an allocation-free variant of rb_class_path that is safe to use from this context.

#2 Updated by Hiroshi SHIBATA over 1 year ago

  • Category set to core
  • Assignee set to Aman Gupta
  • Target version set to 2.1.0

#3 Updated by Nobuyoshi Nakada over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r44088.
Alexey, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


object_tracing.c: fix allocation from NEWOBJ hook

  • ext/objspace/object_tracing.c (newobj_i): use cached class path only to get rid object allocation during NEWOBJ hook. [Bug #9212]

Also available in: Atom PDF