ruby/test/objspace
Peter Zhu 516a6cd1ad Check whether object is valid in allocation_info_tracer_compact
When reference updating ObjectSpace.trace_object_allocations, we need to
check whether the object is valid or not because it does not mark the
object so the object may be dead. This can cause a segmentation fault
if the object is on a free heap page.

For example, the following script crashes:

    require "objspace"

    objs = []
    ObjectSpace.trace_object_allocations do
      1_000_000.times do
        objs << Object.new
      end
    end

    objs = nil

    # Free pages that the objs were on
    GC.start

    # Run compaction and check that it doesn't crash
    GC.compact
2024-12-16 12:24:24 -05:00
..
test_objspace.rb Check whether object is valid in allocation_info_tracer_compact 2024-12-16 12:24:24 -05:00
test_ractor.rb Adjust indent [ci skip] 2024-05-04 01:15:09 +09:00