ruby/gc/default
Peter Zhu f2833e358c Fix generational GC for weak references
Fixes issue pointed out in https://bugs.ruby-lang.org/issues/21084#note-7.
The following script crashes:

    wmap = ObjectSpace::WeakMap.new

    GC.disable # only manual GCs
    GC.start
    GC.start

    retain = []
    50.times do
      k = Object.new
      wmap[k] = true
      retain << k
    end

    GC.start # wmap promoted, other objects still young

    retain.clear

    GC.start(full_mark: false)

    wmap.keys.each(&:itself) # call method on keys to cause crash
2025-12-30 10:59:21 -05:00
..