From a4babd8c54ecd3a54184356a605e3c360e918060 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ext/vernier/vernier.cc b/ext/vernier/vernier.cc index 28ba72c..39d8bbc 100644 --- a/ext/vernier/vernier.cc +++ b/ext/vernier/vernier.cc @@ -1554,7 +1554,17 @@ 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; } } };