mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Clear all trace events during teardown
Since0c2d81dada
, not all trace events are cleared during VM teardown. This causes a crash when there is a tracepoint for `RUBY_INTERNAL_EVENT_GC_EXIT` active during teardown. The commit looks like a refactoring commit so I think this change was unintentional. [Bug #16682] (cherry picked from commitb385f7670f
)
This commit is contained in:
parent
0057fe4063
commit
b5fa156b79
4 changed files with 20 additions and 1 deletions
3
eval.c
3
eval.c
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
NORETURN(void rb_raise_jump(VALUE, VALUE));
|
NORETURN(void rb_raise_jump(VALUE, VALUE));
|
||||||
void rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec);
|
void rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec);
|
||||||
|
void rb_ec_clear_all_trace_func(const rb_execution_context_t *ec);
|
||||||
|
|
||||||
static int rb_ec_cleanup(rb_execution_context_t *ec, volatile int ex);
|
static int rb_ec_cleanup(rb_execution_context_t *ec, volatile int ex);
|
||||||
static int rb_ec_exec_node(rb_execution_context_t *ec, void *n);
|
static int rb_ec_exec_node(rb_execution_context_t *ec, void *n);
|
||||||
|
@ -140,7 +141,7 @@ rb_ec_teardown(rb_execution_context_t *ec)
|
||||||
}
|
}
|
||||||
EC_POP_TAG();
|
EC_POP_TAG();
|
||||||
rb_ec_exec_end_proc(ec);
|
rb_ec_exec_end_proc(ec);
|
||||||
rb_ec_clear_current_thread_trace_func(ec);
|
rb_ec_clear_all_trace_func(ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -73,8 +73,16 @@ set_after_gc_start(VALUE module, VALUE proc)
|
||||||
"__set_after_gc_start_tpval__", "__set_after_gc_start_proc__");
|
"__set_after_gc_start_tpval__", "__set_after_gc_start_proc__");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
start_after_gc_exit(VALUE module, VALUE proc)
|
||||||
|
{
|
||||||
|
return set_gc_hook(module, proc, RUBY_INTERNAL_EVENT_GC_EXIT,
|
||||||
|
"__set_after_gc_exit_tpval__", "__set_after_gc_exit_proc__");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_gc_hook(VALUE module)
|
Init_gc_hook(VALUE module)
|
||||||
{
|
{
|
||||||
rb_define_module_function(module, "after_gc_start_hook=", set_after_gc_start, 1);
|
rb_define_module_function(module, "after_gc_start_hook=", set_after_gc_start, 1);
|
||||||
|
rb_define_module_function(module, "after_gc_exit_hook=", start_after_gc_exit, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,4 +79,8 @@ class TestTracepointObj < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_teardown_with_active_GC_end_hook
|
||||||
|
assert_separately([], 'require("-test-/tracepoint"); Bug.after_gc_exit_hook = proc {}')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -276,6 +276,12 @@ rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec)
|
||||||
rb_threadptr_remove_event_hook(ec, rb_ec_thread_ptr(ec), 0, Qundef);
|
rb_threadptr_remove_event_hook(ec, rb_ec_thread_ptr(ec), 0, Qundef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rb_ec_clear_all_trace_func(const rb_execution_context_t *ec)
|
||||||
|
{
|
||||||
|
rb_threadptr_remove_event_hook(ec, MATCH_ANY_FILTER_TH, 0, Qundef);
|
||||||
|
}
|
||||||
|
|
||||||
/* invoke hooks */
|
/* invoke hooks */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue