Closed okuramasafumi closed 3 years ago
Hi @okuramasafumi,
Thank you for reporting this bug. It would be helpful to us if you were able to narrow it down to a smaller reproduction. Could you try removing parts of the benchmark code until you get to the smallest possible script that still reproduces the problem?
It may also be wise to verify if this bug occurs on the latest ruby/ruby build: https://github.com/ruby/ruby
I made some changes to my code but it's hard to reproduce the issue with minimal code. I'll investigate it more.
Thank you, much appreciated.
Instructions to reproduce:
git clone git@github.com:okuramasafumi/alba.git
cd alba
chruby ruby-yjit
ruby benchmark/collection.rb
Relevant output:
Calculating -------------------------------------
<internal:gc>:34: [BUG] Segmentation fault at 0x00007ff026b00000
ruby 3.1.0dev (2021-06-03T19:29:22Z main ab2dcc7104) [x86_64-darwin20]
-- Control frame information -----------------------------------------------
c:0014 p:0010 s:0088 e:000083 METHOD <internal:gc>:34
c:0013 p:0011 s:0076 e:000075 METHOD /Users/maximecb/.gem/ruby/3.1.0/gems/memory_profiler-0.9.14/lib/memory_profiler/reporter.rb:37
c:0012 p:0003 s:0072 e:000071 METHOD /Users/maximecb/.gem/ruby/3.1.0/gems/memory_profiler-0.9.14/lib/memory_profiler/reporter.rb:72
c:0011 p:0015 s:0067 e:000066 METHOD /Users/maximecb/.gem/ruby/3.1.0/gems/memory_profiler-0.9.14/lib/memory_profiler/reporter.rb:33
c:0010 p:0021 s:0061 e:000060 METHOD /Users/maximecb/.gem/ruby/3.1.0/gems/memory_profiler-0.9.14/lib/memory_profiler.rb:15
c:0009 p:0017 s:0055 e:000054 METHOD /Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory/job/task.rb:45
c:0008 p:0004 s:0050 e:000049 METHOD /Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory/job/task.rb:37
c:0007 p:0037 s:0045 e:000044 METHOD /Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory/job.rb:104
c:0006 p:0006 s:0038 e:000037 BLOCK /Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory/job.rb:82 [FINISH]
c:0005 p:---- s:0033 e:000032 CFUNC :each
c:0004 p:0018 s:0029 e:000028 METHOD /Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory/job.rb:81
c:0003 p:0044 s:0025 e:000024 METHOD /Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory.rb:27
c:0002 p:0734 s:0018 E:001730 EVAL benchmark/collection.rb:378 [FINISH]
c:0001 p:0000 s:0003 E:002500 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
benchmark/collection.rb:378:in `<main>'
/Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory.rb:27:in `memory'
/Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory/job.rb:81:in `run'
/Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory/job.rb:81:in `each'
/Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory/job.rb:82:in `block in run'
/Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory/job.rb:104:in `run_task'
/Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory/job/task.rb:37:in `call'
/Users/maximecb/.gem/ruby/3.1.0/gems/benchmark-memory-0.1.2/lib/benchmark/memory/job/task.rb:45:in `while_measuring_memory_usage'
/Users/maximecb/.gem/ruby/3.1.0/gems/memory_profiler-0.9.14/lib/memory_profiler.rb:15:in `report'
/Users/maximecb/.gem/ruby/3.1.0/gems/memory_profiler-0.9.14/lib/memory_profiler/reporter.rb:33:in `report'
/Users/maximecb/.gem/ruby/3.1.0/gems/memory_profiler-0.9.14/lib/memory_profiler/reporter.rb:72:in `run'
/Users/maximecb/.gem/ruby/3.1.0/gems/memory_profiler-0.9.14/lib/memory_profiler/reporter.rb:37:in `start'
<internal:gc>:34:in `start'
It seems to be segfaulting in yjit_free_block
.
@maximecb Thanks for pasting info, I was trying to find more precise cause by removing some code from my benchmak, but couldn't find one.
From my attempts, it seems possible that one of the causes is to use both benchmark-ips
and benchmark-memory
at the same time. When using only benchmark-ips
it didn't reproduce.
I tried to reproduce this bug with latest CRuby (commit: 3208a5df2dfb429752a130a36274464e9924cf44) but it didn't reproduce.
I tried to simplify it too but it proved difficult. We're going to investigate it tomorrow and try to catch the segfault with lldb.
The bug is now fixed. Sorry it took so long! :)
@maximecb Cool, thank you!
When I run my benchmark with yjit it sometimes crashes.
Here are some outputs (I tried to paste .crash file here but it's not accepted):