diff options
author | Peter Zhu <peter@peterzhu.ca> | 2021-12-02 11:16:53 -0500 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2021-12-02 13:06:44 -0500 |
commit | 9f0c6f20c58067923864575b60af730d191b8f6c (patch) | |
tree | 0e6e81f7a77b571271025c5f9bd9c1572a570527 | |
parent | fbc16157615570ca5abc66a3ecfc30a0de7e9d49 (diff) | |
download | ruby-9f0c6f20c58067923864575b60af730d191b8f6c.tar.gz |
[Bug #18382] Fix crash in compaction for ObjectSpace.trace_object_allocations
ObjectSpace.trace_object_allocations can crash when auto-compaction is
enabled.
-rw-r--r-- | ext/objspace/object_tracing.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/objspace/object_tracing.c b/ext/objspace/object_tracing.c index 4973a7535b..66d6baa491 100644 --- a/ext/objspace/object_tracing.c +++ b/ext/objspace/object_tracing.c @@ -208,7 +208,8 @@ allocation_info_tracer_compact(void *ptr) { 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"); } } |