Repository navigation
[Bug #22412] Copy ep when duplicating ifunc procs - #19251
Merged
Merged
Conversation
[Bug #22412]
When duplicating ifunc procs that have heap allocated env, we should share
it instead of making a copy.
In debug mode, the following script triggers an assertion failure:
pr = proc {|a, b| [a, b] }.curry.dup
pr.call(1)
It crashes with:
vm.c:281: Assertion Failed: vm_ep_in_heap_p_:env->ep == ep
ruby 4.1.0dev (2026-10-07T07:57:31Z master 9ce0df6) +PRISM [arm64-darwin27]
-- Crash Report log information --------------------------------------------
See Crash Report log file in one of the following locations:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
-- Control frame information -----------------------------------------------
c:0004 p:---- s:0014 e:000013 l:y b:0001 r:0x0 CFUNC :proc
c:0003 p:---- s:0011 e:000010 l:n b:---- r:0x0 IFUNC
c:0002 p:0015 s:0008 E:001e90 l:n b:---- r:0x0 EVAL test.rb:2 [FINISH]
c:0001 p:0000 s:0003 E:001ff8 l:y b:---- r:0x0 DUMMY [FINISH]
-- Ruby level backtrace information ----------------------------------------
test.rb:2:in '<main>'
test.rb:2:in 'proc'
-- Threading information ---------------------------------------------------
Total ractor count: 1
Ruby thread count for this ractor: 1
-- C level backtrace information -------------------------------------------
miniruby(rb_assert_failure_detail+0xf0) [0x105456fe4] error.c:1268
miniruby(rb_assert_failure_detail) (null):0
miniruby(rb_assert_failure_detail+0x0) [0x105456ef4] error.c:1244
miniruby(rb_assert_failure) (null):0
miniruby(vm_ep_in_heap_p_.cold.1+0x28) [0x105463d24] vm.c:281
miniruby(vm_ep_in_heap_p_.cold.2) (null):0
miniruby(rb_vm_cref_dup+0x0) [0x10519a4e4] vm.c:281
miniruby(vm_ep_in_heap_p_) (null):0
miniruby(VM_ENV_ESCAPED_P+0x68) [0x1051ba188] vm.c:295
miniruby(vm_make_env_each+0xa4) [0x1051d56c8] vm.c:1120
miniruby(vm_make_env_object+0x8) [0x1051b9f18] vm.c:1217
miniruby(rb_vm_make_proc_lambda) vm.c:1720
miniruby(vm_call0_body+0x778) [0x1051d39dc] vm_eval.c:164
miniruby(rb_call0+0x2ac) [0x1051d47e0] vm_eval.c:101
miniruby(rb_iterate0+0x1d0) [0x1051b5e04] vm_eval.c:1506
miniruby(rb_block_call_kw+0x28) [0x1051b59a4] vm_eval.c:1580
miniruby(rb_block_call) vm_eval.c:1566
miniruby(RB_SPECIAL_CONST_P+0x0) [0x105096de0] proc.c:4236
miniruby(rbimpl_RB_TYPE_P_fastpath) include/ruby/internal/value_type.h:349
miniruby(rbimpl_obj_typeddata_p) include/ruby/internal/core/rtypeddata.h:661
miniruby(rb_proc_new) include/ruby/internal/core/rtypeddata.h:735
miniruby(make_curry_proc) proc.c:4524
miniruby(vm_yield_with_cfunc+0xc0) [0x10519de40] vm_insnhelper.c:5275
miniruby(vm_invoke_ifunc_block+0xe0) [0x1051cd8bc] vm_insnhelper.c:5539
miniruby(vm_exec_core+0x42ec) [0x1051a5d48] vm_insnhelper.c:6285
miniruby(vm_exec_loop+0x0) [0x10519f240] vm.c:2909
miniruby(rb_vm_exec) vm.c:2912
miniruby(rb_ec_exec_node+0xa0) [0x104fac450] eval.c:300
miniruby(ruby_run_node+0x64) [0x104fac354] eval.c:338
miniruby(rb_main+0x1c) [0x104ee09b0] main.c:42
miniruby(main) main.c:62
|
This pull request references the following Redmine tickets: |
peterzhu2118
force-pushed
the
ifunc-proc-dup
branch
from
October 7, 2026 14:22
7894cd4 to
4e58ba4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When duplicating ifunc procs that have heap allocated env, we should share it instead of making a copy.
In debug mode, the following script triggers an assertion failure:
It crashes with: