summaryrefslogtreecommitdiff
path: root/ext/gdbm/testgdbm.rb
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2026-06-03 17:39:07 -0700
committerJohn Hawthorn <john@hawthorn.email>2026-06-05 10:56:16 -0700
commitdd9213c41de9447383708aed32d64211f0697506 (patch)
tree9061689b9181d25a9b2856ca1e701c2f2ae60f38 /ext/gdbm/testgdbm.rb
parenta2433947b767b7387bd70c71221df4e22f38985e (diff)
Convert object_tracing to use weak referencesHEADmaster
Object tracing listens to the NEWOBJ hook to see all objects allocated while it is active. Previously it also enabled a FREEOBJ tracepoint to drop each object's record as the object was freed. However the FREEOBJ tracepoint only fires while tracing is active. An object recorded during tracing can be freed after tracing stops, and that free was missed, leaving a stale record in object_table keyed by a freed object. These dangling keys are unsafe during compaction, which was previously mitigated with rb_gc_pointer_to_heap_p (which I'd like to stop using). These dangling keys could also become incorrectly associated with a new object allocated in its place. Instead we can declare object_table's keys as weak references. The GC then invokes our weak reference callback on every collection, whether or not tracing is running, letting us reap the records of objects about to be freed. This callback runs before the FREEOBJ hook, which makes the FREEOBJ tracepoint unnecessary.
Diffstat (limited to 'ext/gdbm/testgdbm.rb')
0 files changed, 0 insertions, 0 deletions