Skip to content
  • NARUSE, Yui's avatar
    400ccb16
    merge revision(s) cb22d783: [Backport #19536] · 400ccb16
    NARUSE, Yui authored
    	Fix frozen status loss when moving objects
    
    	[Bug #19536]
    
    	When objects are moved between size pools, their frozen status is lost
    	in the shape. This will cause the frozen check to be bypassed when there
    	is an inline cache. For example, the following script should raise a
    	FrozenError, but doesn't on Ruby 3.2 and master.
    
    	    class A
    	      def add_ivars
    	        @a = @b = @c = @d = 1
    	      end
    
    	      def set_a
    	        @a = 10
    	      end
    	    end
    
    	    a = A.new
    	    a.add_ivars
    	    a.freeze
    
    	    b = A.new
    	    b.add_ivars
    	    b.set_a # Set the inline cache in set_a
    
    	    GC.verify_compaction_references(expand_heap: true, toward: :empty)
    
    	    a.set_a
    	---
    	 shape.c                      |  2 +-
    	 test/ruby/test_gc_compact.rb | 28 ++++++++++++++++++++++++++++
    	 2 files changed, 29 insertions(+), 1 deletion(-)
    400ccb16
    merge revision(s) cb22d783: [Backport #19536]
    NARUSE, Yui authored
    	Fix frozen status loss when moving objects
    
    	[Bug #19536]
    
    	When objects are moved between size pools, their frozen status is lost
    	in the shape. This will cause the frozen check to be bypassed when there
    	is an inline cache. For example, the following script should raise a
    	FrozenError, but doesn't on Ruby 3.2 and master.
    
    	    class A
    	      def add_ivars
    	        @a = @b = @c = @d = 1
    	      end
    
    	      def set_a
    	        @a = 10
    	      end
    	    end
    
    	    a = A.new
    	    a.add_ivars
    	    a.freeze
    
    	    b = A.new
    	    b.add_ivars
    	    b.set_a # Set the inline cache in set_a
    
    	    GC.verify_compaction_references(expand_heap: true, toward: :empty)
    
    	    a.set_a
    	---
    	 shape.c                      |  2 +-
    	 test/ruby/test_gc_compact.rb | 28 ++++++++++++++++++++++++++++
    	 2 files changed, 29 insertions(+), 1 deletion(-)
Loading