[ruby-core:112982] [Ruby master Bug#19536] Frozen status loss when moving objects
From:
"naruse (Yui NARUSE) via ruby-core" <ruby-core@...>
Date:
2023-03-23 03:03:41 UTC
List:
ruby-core #112982
Issue #19536 has been updated by naruse (Yui NARUSE).
Backport changed from 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONE
ruby_3_2 400ccb16eefe4e21c4e3eacab4fd0f208fc5e151 merged revision(s) cb22d78354e201ca74eba68a8b4edefb593e6754.
----------------------------------------
Bug #19536: Frozen status loss when moving objects
https://bugs.ruby-lang.org/issues/19536#change-102512
* Author: peterzhu2118 (Peter Zhu)
* Status: Closed
* Priority: Normal
* Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONE
----------------------------------------
GitHub PR: https://github.com/ruby/ruby/pull/7553
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.
```ruby
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
```
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/