Without doing this, enabling a TracePoint on a method could lead to use
of moved objects. This was found by running env RUBY_ISEQ_DUMP_DEBUG=to_binary make test-all, which sets
orignal_iseq then runs the compaction tests and the tracepoint tests.
Please excuse the lack of tests. I was not able to figure out how to
reliably trigger a move on a specific iseq imemo to make a good
regression test.
To manually confirm the problem and this fix, you can run:
env RUBY_ISEQ_DUMP_DEBUG=to_binary make test-all \
TESTOPTS="test/ruby/test_gc_compact.rb \
test/gdbm/test_gdbm.rb \
test/ruby/test_settracefunc.rb"
Or the following script:
tp=TracePoint.new(:line){}1.timesdo# put it in a block to not keep these objects aliveobjects=10_000.times.map{Object.new}objects.hashend1.timesdo# this allocation pattern can realistically happen in an app# at load timebeek=10_000.times.mapdoeval(<<-RUBY)
def foo
a + b
1.times {
4 + 234234
}
nil + 234
end
RUBYObject.newObject.newendbeek.hashendtp.enable(target: self.:foo){234}# allocate original iseqGC.verify_compaction_references(toward: :empty)GC.compacttp.enable(target: self.:foo){234234}# crash
Update moved objects in original_iseq
Without doing this, enabling a TracePoint on a method could lead to use
of moved objects. This was found by running
env RUBY_ISEQ_DUMP_DEBUG=to_binary make test-all
, which setsorignal_iseq then runs the compaction tests and the tracepoint tests.
Please excuse the lack of tests. I was not able to figure out how to
reliably trigger a move on a specific iseq imemo to make a good
regression test.
To manually confirm the problem and this fix, you can run:
Or the following script:
[Bug #16098]