ruby-changes:70029
From: Peter <ko1@a...>
Date: Fri, 3 Dec 2021 03:06:57 +0900 (JST)
Subject: [ruby-changes:70029] 9f0c6f20c5 (master): [Bug #18382] Fix crash in compaction for ObjectSpace.trace_object_allocations
https://git.ruby-lang.org/ruby.git/commit/?id=9f0c6f20c5 From 9f0c6f20c58067923864575b60af730d191b8f6c Mon Sep 17 00:00:00 2001 From: Peter Zhu <peter@p...> Date: Thu, 2 Dec 2021 11:16:53 -0500 Subject: [Bug #18382] Fix crash in compaction for ObjectSpace.trace_object_allocations ObjectSpace.trace_object_allocations can crash when auto-compaction is enabled. --- ext/objspace/object_tracing.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/objspace/object_tracing.c b/ext/objspace/object_tracing.c index 4973a7535ba..66d6baa4911 100644 --- a/ext/objspace/object_tracing.c +++ b/ext/objspace/object_tracing.c @@ -208,7 +208,8 @@ allocation_info_tracer_compact(void *ptr) https://github.com/ruby/ruby/blob/trunk/ext/objspace/object_tracing.c#L208 { struct traceobj_arg *trace_arg = (struct traceobj_arg *)ptr; - if (st_foreach_with_replace(trace_arg->object_table, hash_foreach_should_replace_key, hash_replace_key, 0)) { + if (trace_arg->object_table && + st_foreach_with_replace(trace_arg->object_table, hash_foreach_should_replace_key, hash_replace_key, 0)) { rb_raise(rb_eRuntimeError, "hash modified during iteration"); } } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/