Project

General

Profile

Actions

Bug #19482

closed

Fix crash when allocating classes with newobj hook

Added by peterzhu2118 (Peter Zhu) about 1 year ago. Updated 9 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:112721]

Description

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:

require "objspace"

GC.stress = true

ObjectSpace.trace_object_allocations {
  100.times do
    Class.new
  end
}
Actions #1

Updated by peterzhu2118 (Peter Zhu) about 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|e1bd45624c85e8a80991bda20801f50967ac77a1.


Fix crash when allocating classes with newobj hook

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:

require "objspace"

GC.stress = true

ObjectSpace.trace_object_allocations {
  100.times do
    Class.new
  end
}

[Bug #19482]

Updated by nagachika (Tomoyuki Chikanaga) 9 months ago

  • 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 141402d11c09fa641eebd8f4841f81e7bbf3518c merged revision(s) e1bd45624c85e8a80991bda20801f50967ac77a1.

Actions

Also available in: Atom PDF

Like0
Like0Like0