[ruby-core:112721] [Ruby master Bug#19482] Fix crash when allocating classes with newobj hook
From:
"peterzhu2118 (Peter Zhu) via ruby-core" <ruby-core@...>
Date:
2023-03-07 14:54:36 UTC
List:
ruby-core #112721
Issue #19482 has been reported by peterzhu2118 (Peter Zhu).
----------------------------------------
Bug #19482: Fix crash when allocating classes with newobj hook
https://bugs.ruby-lang.org/issues/19482
* Author: peterzhu2118 (Peter Zhu)
* Status: Open
* Priority: Normal
* Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED
----------------------------------------
GitHub PR: https://github.com/ruby/ruby/pull/7464
We need to zero out the whole slot when running the newobj hook for a newly allocated class because the slot could be filled with garbage, which would cause a crash if a GC runs inside of the newobj hook.
For example, the following script crashes:
```ruby
require "objspace"
GC.stress = true
ObjectSpace.trace_object_allocations {
100.times do
Class.new
end
}
```
--
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/