mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 12:34:21 +00:00
ZJIT: Fix assertion failure when profiling VM_BLOCK_HANDLER_NONE
As can be seen in vm_block_handler_verify(), VM_BLOCK_HANDLER_NONE is not a valid argument for vm_block_handler(). Store nil in the profiler when seen instead of crashing.
This commit is contained in:
parent
4107a41020
commit
2cd792a1cf
Notes:
git
2025-11-19 23:14:30 +00:00
@ -6041,11 +6041,14 @@ vm_define_method(const rb_execution_context_t *ec, VALUE obj, ID id, VALUE iseqv
|
||||
}
|
||||
|
||||
// Return the untagged block handler:
|
||||
// * If it's VM_BLOCK_HANDLER_NONE, return nil
|
||||
// * If it's an ISEQ or an IFUNC, fetch it from its rb_captured_block
|
||||
// * If it's a PROC or SYMBOL, return it as is
|
||||
static VALUE
|
||||
rb_vm_untag_block_handler(VALUE block_handler)
|
||||
{
|
||||
if (VM_BLOCK_HANDLER_NONE == block_handler) return Qnil;
|
||||
|
||||
switch (vm_block_handler_type(block_handler)) {
|
||||
case block_handler_type_iseq:
|
||||
case block_handler_type_ifunc: {
|
||||
|
||||
@ -361,3 +361,17 @@ impl IseqProfile {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cruby::*;
|
||||
|
||||
#[test]
|
||||
fn can_profile_block_handler() {
|
||||
with_rubyvm(|| eval("
|
||||
def foo = yield
|
||||
foo rescue 0
|
||||
foo rescue 0
|
||||
"));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user