Commit Graph

1 Commits

Author SHA1 Message Date
Andreas Kling
323e7dd79d LibGC: Add GC::WeakHashSet<T> for safe weak pointer hash sets
HashTable<GC::Weak<T>> is unsafe because GC::Weak's hash depends on
ptr() which becomes nullptr when the object is collected. This corrupts
the hash table: entries shift to wrong buckets, probe chains break
during delete_bucket(), and rehash scatters dead entries incorrectly.

WeakHashSet wraps HashTable with private internal traits that own the
hash function, prunes dead entries before every mutation, and provides
an iterator that skips dead entries and yields T& directly.
2026-02-24 22:35:03 +01:00