зеркало из https://github.com/github/ruby.git
should not free local hook_list here.
exec_hooks_postcheck() clean executed hook_list if it is needed. list_exec is freed if there are no events and this list is local event (connected to specific iseq). However, iseq keeps to point this local hook_list, freed list. To prevent this situation, do not free hook_list here even if it has no events. This issue is reported by @joker1007. https://twitter.com/joker1007/status/1153649170797830144
This commit is contained in:
Родитель
a4e5690760
Коммит
df317151a5
|
@ -2166,4 +2166,21 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||
tp.enable {obj.example}
|
||||
assert ok, "return event should be emitted"
|
||||
end
|
||||
|
||||
def test_disable_local_tracepoint_in_trace
|
||||
assert_normal_exit <<-EOS
|
||||
def foo
|
||||
trace = TracePoint.new(:b_return){|tp|
|
||||
tp.disable
|
||||
}
|
||||
trace.enable(target: method(:bar))
|
||||
end
|
||||
def bar
|
||||
100.times{|i|
|
||||
foo; foo
|
||||
}
|
||||
end
|
||||
bar
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
|
|
@ -198,9 +198,6 @@ clean_hooks(const rb_execution_context_t *ec, rb_hook_list_t *list)
|
|||
}
|
||||
else {
|
||||
/* local events */
|
||||
if (list->events == 0) {
|
||||
ruby_xfree(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче