Actions
Bug #19922
closedObjectSpace.dump_all in multiple threads in parallel causes SEGV
Bug #19922:
ObjectSpace.dump_all in multiple threads in parallel causes SEGV
Description
ObjectSpace.dump_all in multiple threads in parallel causes SEGV.
The reproduce code is here:
$ ruby -robjspace -e 'def dump; 10.times { ObjectSpace.dump_all } end; Thread.new { dump }; dump'
/home/wanabe/.rbenv/versions/master/lib/ruby/3.3.0+0/objspace.rb:100: [BUG] Segmentation fault at 0x0000000000000000
(snip)
I attached the full log.
I assumed that:
- Thread1
- calls
rb_objspace_reachable_objects_from_root() - changes
GET_RACTOR()->mfd: mfd1 - calls
dump_flush()- changes current thread due to IO
- calls
- Thread2
- calls
rb_objspace_reachable_objects_from_root() - changes
GET_RACTOR()->mfd: mfd2 - calls
dump_flush()- changes current thread due to IO
- calls
- Thread1
- gets unexpected
GET_RACTOR()->mfd: mfd2
- gets unexpected
Files
Updated by kjtsanaktsidis (KJ Tsanaktsidis) over 2 years ago
I think your diagnosis is correct, and that https://github.com/ruby/ruby/pull/8858 should fix this - does it look reasonable to you?
Updated by wanabe (_ wanabe) over 2 years ago
Thank you. https://github.com/ruby/ruby/pull/8858 resolves my issue.
Updated by byroot (Jean Boussier) over 2 years ago
- Status changed from Open to Closed
Fixed in 76dc327eeffefe02577999fe5f8215f762a581b6 and 9a62fd3cbae2ebb60e2f9cad782af1ad18db4319
Updated by byroot (Jean Boussier) over 2 years ago
- Status changed from Closed to Open
Reopening because the fix caused a failure on ruby-ci, so we'll revert for now.
Updated by wanabe (_ wanabe) 5 days ago
- Status changed from Open to Closed
This issue was fixed in commit 3c63a01295b4219743b3d3e883fd4a4a616960a and has not recurred since then.
Thank you.
$ git checkout 3c63a01295b4219743b3d3e883fd4a4a616960a6; make -j8 exts >/dev/null 2>&1 && ./ruby -v -I .ext/x86_64-linux/ -I .ext/common/ -I ../../lib -I. -robjspace -e 'def dump; 100.times { ObjectSpace.dump_all } end; Thread.new { dump }; dump; p :ok' 2>&1|head -n2
HEAD is now at 3c63a01295 Move responsibility of heap walking into Ruby
ruby 3.4.0dev (2024-09-03T14:05:38Z v3_4_0_preview2~649 3c63a01295) [x86_64-linux]
:ok
$ git checkout 3c63a01295b4219743b3d3e883fd4a4a616960a6~; make -j8 exts >/dev/null 2>&1 && ./ruby -v -I .ext/x86_64-linux/ -I .ext/common/ -I ../../lib -I. -robjspace -e 'def dump; 100.times { ObjectSpace.dump_all } end; Thread.new { dump }; dump; p :ok' 2>&1|head -n2
Previous HEAD position was 3c63a01295 Move responsibility of heap walking into Ruby
HEAD is now at a2243ee48b Implement ALIAS NODE keyword locations
ruby 3.4.0dev (2024-09-03T13:09:08Z v3_4_0_preview2~650 a2243ee48b) [x86_64-linux]
/home/wanabe/work/prog/ruby/ruby/tmp/master/.ext/common/objspace.rb:100: [BUG] Segmentation fault at 0x0000000000000000
Actions