Skip to content
  • nagachika's avatar
    ee3428aa
    merge revision(s) 56ecc243: [Backport #20868] · ee3428aa
    nagachika authored
    	[Bug #20868] Fix Method#hash to not change after compaction
    
    	The hash value of a Method must remain constant after a compaction, otherwise
    	it may not work as the key in a hash table.
    
    	For example:
    
    	    def a; end
    
    	    # Need this method here because otherwise the iseq may be on the C stack
    	    # which would get pinned and not move during compaction
    	    def get_hash
    	      method(:a).hash
    	    end
    
    	    puts get_hash # => 2993401401091578131
    
    	    GC.verify_compaction_references(expand_heap: true, toward: :empty)
    
    	    puts get_hash # => -2162775864511574135
    ee3428aa
    merge revision(s) 56ecc243: [Backport #20868]
    nagachika authored
    	[Bug #20868] Fix Method#hash to not change after compaction
    
    	The hash value of a Method must remain constant after a compaction, otherwise
    	it may not work as the key in a hash table.
    
    	For example:
    
    	    def a; end
    
    	    # Need this method here because otherwise the iseq may be on the C stack
    	    # which would get pinned and not move during compaction
    	    def get_hash
    	      method(:a).hash
    	    end
    
    	    puts get_hash # => 2993401401091578131
    
    	    GC.verify_compaction_references(expand_heap: true, toward: :empty)
    
    	    puts get_hash # => -2162775864511574135
Loading