From 2e6e2fd9da18b74aa9555d09a871b24895e42773 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 13 Dec 2021 02:15:05 +0900 Subject: fix local TP memory leak It free `rb_hook_list_t` itself if needed. To recognize the need, this patch introduced `rb_hook_list_t::is_local` flag. This patch is succession of https://github.com/ruby/ruby/pull/4652 --- iseq.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'iseq.c') diff --git a/iseq.c b/iseq.c index 21622fa288..9538847577 100644 --- a/iseq.c +++ b/iseq.c @@ -3359,6 +3359,7 @@ iseq_add_local_tracepoint(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, if (n > 0) { if (iseq->aux.exec.local_hooks == NULL) { ((rb_iseq_t *)iseq)->aux.exec.local_hooks = RB_ZALLOC(rb_hook_list_t); + iseq->aux.exec.local_hooks->is_local = true; } rb_hook_list_connect_tracepoint((VALUE)iseq, iseq->aux.exec.local_hooks, tpval, target_line); } @@ -3413,9 +3414,7 @@ iseq_remove_local_tracepoint(const rb_iseq_t *iseq, VALUE tpval) local_events = iseq->aux.exec.local_hooks->events; if (local_events == 0) { - if (iseq->aux.exec.local_hooks->running == 0) { - rb_hook_list_free(iseq->aux.exec.local_hooks); - } + rb_hook_list_free(iseq->aux.exec.local_hooks); ((rb_iseq_t *)iseq)->aux.exec.local_hooks = NULL; } -- cgit v1.2.3