Remove EC argument from clean_hooks_check

This argument doesn't seem used anymore. Since we want to free these
objects during VM destruction when RUBY_FREE_AT_EXIT is set they must
work without an EC.

This avoids a use-after-free running `RUBY_FREE_AT_EXIT=1 ./miniruby -e ''`
This commit is contained in:
John Hawthorn 2023-12-16 01:34:03 -08:00
parent 24ff13d8da
commit 697a096c9b

View File

@ -82,7 +82,7 @@ rb_hook_list_mark_and_update(rb_hook_list_t *hooks)
}
}
static void clean_hooks(const rb_execution_context_t *ec, rb_hook_list_t *list);
static void clean_hooks(rb_hook_list_t *list);
void
rb_hook_list_free(rb_hook_list_t *hooks)
@ -90,7 +90,7 @@ rb_hook_list_free(rb_hook_list_t *hooks)
hooks->need_clean = true;
if (hooks->running == 0) {
clean_hooks(GET_EC(), hooks);
clean_hooks(hooks);
}
}
@ -223,7 +223,7 @@ rb_add_event_hook2(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data
}
static void
clean_hooks(const rb_execution_context_t *ec, rb_hook_list_t *list)
clean_hooks(rb_hook_list_t *list)
{
rb_event_hook_t *hook, **nextp = &list->hooks;
rb_event_flag_t prev_events = list->events;
@ -257,11 +257,11 @@ clean_hooks(const rb_execution_context_t *ec, rb_hook_list_t *list)
}
static void
clean_hooks_check(const rb_execution_context_t *ec, rb_hook_list_t *list)
clean_hooks_check(rb_hook_list_t *list)
{
if (UNLIKELY(list->need_clean)) {
if (list->running == 0) {
clean_hooks(ec, list);
clean_hooks(list);
}
}
}
@ -289,7 +289,7 @@ remove_event_hook(const rb_execution_context_t *ec, const rb_thread_t *filter_th
hook = hook->next;
}
clean_hooks_check(ec, list);
clean_hooks_check(list);
return ret;
}
@ -373,7 +373,7 @@ static void
exec_hooks_postcheck(const rb_execution_context_t *ec, rb_hook_list_t *list)
{
list->running--;
clean_hooks_check(ec, list);
clean_hooks_check(list);
}
static void