summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2024-12-13 12:20:01 -0500
committerPeter Zhu <[email protected]>2024-12-16 10:12:54 -0500
commitb0385305060e6edf98f92993f3f13c5e6a978b0e (patch)
treea2c2389a7afea5d99686ece468e303a5338168c6
parent39d0ebb6e84a68ef6b5b43f33fb32f36428be548 (diff)
Fix compaction check for ObjectSpace.trace_object_allocations
We should be checking for key for moved objects rather than the value because the key is a Ruby object and the value is malloc'd memory.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12339
-rw-r--r--ext/objspace/object_tracing.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/ext/objspace/object_tracing.c b/ext/objspace/object_tracing.c
index c1c93c51f5..b92fda6826 100644
--- a/ext/objspace/object_tracing.c
+++ b/ext/objspace/object_tracing.c
@@ -192,9 +192,7 @@ allocation_info_tracer_memsize(const void *ptr)
static int
hash_foreach_should_replace_key(st_data_t key, st_data_t value, st_data_t argp, int error)
{
- VALUE allocated_object;
-
- allocated_object = (VALUE)value;
+ VALUE allocated_object = (VALUE)key;
if (allocated_object != rb_gc_location(allocated_object)) {
return ST_REPLACE;
}