From 162275e01016b4fce49ed1052c75bc757a2411d6 Mon Sep 17 00:00:00 2001 From: Joshua Young Date: Thu, 24 Oct 2024 19:30:41 +1000 Subject: [PATCH] Update collector->object_frames to reflect object_list move --- ext/vernier/vernier.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ext/vernier/vernier.cc b/ext/vernier/vernier.cc index 28ba72c..10d5911 100644 --- a/ext/vernier/vernier.cc +++ b/ext/vernier/vernier.cc @@ -1554,7 +1554,16 @@ class RetainedCollector : public BaseCollector { void compact() { RetainedCollector *collector = this; for (auto& obj: collector->object_list) { - obj = rb_gc_location(obj); + VALUE reloc_obj = rb_gc_location(obj); + + const auto search = collector->object_frames.find(obj); + if (search != collector->object_frames.end()) { + int stack_index = search->second; + collector->object_frames.erase(search); + collector->object_frames.emplace(reloc_obj, stack_index); + } + + obj = reloc_obj; } } };