1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[Bug #18382] Fix crash in compaction for ObjectSpace.trace_object_allocations

ObjectSpace.trace_object_allocations can crash when auto-compaction is
enabled.
This commit is contained in:
Peter Zhu 2021-12-02 11:16:53 -05:00
parent fbc1615761
commit 9f0c6f20c5
Notes: git 2021-12-03 03:07:05 +09:00

View file

@ -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");
}
}