summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2021-12-13 02:15:05 +0900
committerKoichi Sasada <ko1@atdot.net>2021-12-15 02:31:58 +0900
commit2e6e2fd9da18b74aa9555d09a871b24895e42773 (patch)
tree5efb6f4618b6d61d50b2e4efd2893a88af81729b /iseq.c
parentb8f7fc361d2cf2266e39e97c57bba6edd6c6edaf (diff)
downloadruby-2e6e2fd9da18b74aa9555d09a871b24895e42773.tar.gz
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
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c5
1 files changed, 2 insertions, 3 deletions
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;
}