Guard against GC of random ISEQs

This commit is contained in:
Takashi Kokubun 2023-03-01 22:06:57 -08:00
parent 7dcdffebc8
commit 706f6272d9
Notes: git 2023-03-06 07:29:49 +00:00
3 changed files with 18 additions and 0 deletions

View file

@ -143,6 +143,9 @@ module RubyVM::MJIT
def invalidate_block(block)
iseq = block.iseq
# Avoid touching GCed ISEQs. We assume it won't be re-entered.
return if C.imemo_type(iseq) != C.imemo_iseq
# Remove this block from the version array
remove_block(iseq, block)
@ -286,6 +289,11 @@ module RubyVM::MJIT
end
def mjit_blocks(iseq)
# Tolerate GC on any ISEQ
if C.imemo_type(iseq) != C.imemo_iseq
return Hash.new { |h, k| h[k] = {} }
end
unless iseq.body.mjit_blocks
iseq.body.mjit_blocks = Hash.new { |h, k| h[k] = {} }
# For some reason, rb_mjit_iseq_mark didn't protect this Hash