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:
Koichi Sasada 2019-07-24 05:32:09 +09:00
Родитель a4e5690760
Коммит df317151a5
2 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@ -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);
}
}
}