summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorAlan Wu <[email protected]>2025-03-10 22:37:44 -0400
committerAlan Wu <[email protected]>2025-03-12 15:00:26 -0400
commit08b3a45bc97c835b4677bf76dbce68fd51d81897 ()
tree6ed517372f764d8cf9da9212b5428307b8471e73 /vm.c
parent9b9661883b1e2cc85b1341d804b106885432d2bd (diff)
Push a real iseq in rb_vm_push_frame_fname()
Previously, vm_make_env_each() (used during proc creation and for the debug inspector C API) picked up the non-GC-allocated iseq that rb_vm_push_frame_fname() creates, which led to a SEGV when the GC tried to mark the non GC object. Put a real iseq imemo instead. Speed should be about the same since the old code also did a imemo allocation and a malloc allocation. Real iseq allows ironing out the special-casing of dummy frames in rb_execution_context_mark() and rb_execution_context_update(). A check is added to RubyVM::ISeq#eval, though, to stop attempts to run dummy iseqs. [Bug #21180] Co-authored-by: Aaron Patterson <[email protected]>
Notes: Merged: https://.com/ruby/ruby/pull/12898
-rw-r--r--vm.c52
1 files changed, 24 insertions, 28 deletions
@@ -3362,22 +3362,20 @@ rb_execution_context_update(rb_execution_context_t *ec)
}
while (cfp != limit_cfp) {
- if (VM_FRAME_TYPE(cfp) != VM_FRAME_MAGIC_DUMMY) {
- const VALUE *ep = cfp->ep;
- cfp->self = rb_gc_location(cfp->self);
- cfp->iseq = (rb_iseq_t *)rb_gc_location((VALUE)cfp->iseq);
- cfp->block_code = (void *)rb_gc_location((VALUE)cfp->block_code);
-
- if (!VM_ENV_LOCAL_P(ep)) {
- const VALUE *prev_ep = VM_ENV_PREV_EP(ep);
- if (VM_ENV_FLAGS(prev_ep, VM_ENV_FLAG_ESCAPED)) {
- VM_FORCE_WRITE(&prev_ep[VM_ENV_DATA_INDEX_ENV], rb_gc_location(prev_ep[VM_ENV_DATA_INDEX_ENV]));
- }
- if (VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED)) {
- VM_FORCE_WRITE(&ep[VM_ENV_DATA_INDEX_ENV], rb_gc_location(ep[VM_ENV_DATA_INDEX_ENV]));
- VM_FORCE_WRITE(&ep[VM_ENV_DATA_INDEX_ME_CREF], rb_gc_location(ep[VM_ENV_DATA_INDEX_ME_CREF]));
- }
}
}
@@ -3413,21 +3411,19 @@ rb_execution_context_mark(const rb_execution_context_t *ec)
const VALUE *ep = cfp->ep;
VM_ASSERT(!!VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED) == vm_ep_in_heap_p_(ec, ep));
- if (VM_FRAME_TYPE(cfp) != VM_FRAME_MAGIC_DUMMY) {
- rb_gc_mark_movable(cfp->self);
- rb_gc_mark_movable((VALUE)cfp->iseq);
- rb_gc_mark_movable((VALUE)cfp->block_code);
- if (!VM_ENV_LOCAL_P(ep)) {
- const VALUE *prev_ep = VM_ENV_PREV_EP(ep);
- if (VM_ENV_FLAGS(prev_ep, VM_ENV_FLAG_ESCAPED)) {
- rb_gc_mark_movable(prev_ep[VM_ENV_DATA_INDEX_ENV]);
- }
- if (VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED)) {
- rb_gc_mark_movable(ep[VM_ENV_DATA_INDEX_ENV]);
- rb_gc_mark(ep[VM_ENV_DATA_INDEX_ME_CREF]);
- }
}
}