Project

General

Profile

Bug #10689 » fix-unexpected-break.patch

ktsj (Kazuki Tsujimoto), 01/02/2015 09:45 AM

View differences:

vm.c
return local_var_list_finish(&vars);
}
static void vm_rewrite_ep_in_errinfo(rb_thread_t *th);
static void vm_rewrite_errinfo_in_stack(rb_thread_t *th);
static VALUE vm_make_proc_from_block(rb_thread_t *th, rb_block_t *block);
static VALUE vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp, VALUE *blockprocptr);
......
}
envval = vm_make_env_each(th, cfp, cfp->ep, lep);
vm_rewrite_ep_in_errinfo(th);
vm_rewrite_errinfo_in_stack(th);
if (PROCDEBUG) {
check_env_value(envval);
......
return envval;
}
void
rb_vm_rewrite_ep_in_errinfo(rb_thread_t *th, VALUE errinfo)
{
/* rewrite ep in errinfo to point to heap */
if (RB_TYPE_P(errinfo, T_NODE)) {
VALUE *escape_ep = GET_THROWOBJ_CATCH_POINT(errinfo);
if (! ENV_IN_HEAP_P(th, escape_ep)) {
VALUE epval = *escape_ep;
if (!SPECIAL_CONST_P(epval) && RBASIC(epval)->klass == rb_cEnv) {
rb_env_t *epenv;
GetEnvPtr(epval, epenv);
SET_THROWOBJ_CATCH_POINT(errinfo, (VALUE)(epenv->env + epenv->local_size));
}
}
}
}
static void
vm_rewrite_ep_in_errinfo(rb_thread_t *th)
vm_rewrite_errinfo_in_stack(rb_thread_t *th)
{
rb_control_frame_t *cfp = th->cfp;
while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {
/* rewrite ep in errinfo to point to heap */
if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) &&
(cfp->iseq->type == ISEQ_TYPE_RESCUE ||
cfp->iseq->type == ISEQ_TYPE_ENSURE)) {
VALUE errinfo = cfp->ep[-2]; /* #$! */
if (RB_TYPE_P(errinfo, T_NODE)) {
VALUE *escape_ep = GET_THROWOBJ_CATCH_POINT(errinfo);
if (! ENV_IN_HEAP_P(th, escape_ep)) {
VALUE epval = *escape_ep;
if (!SPECIAL_CONST_P(epval) && RBASIC(epval)->klass == rb_cEnv) {
rb_env_t *epenv;
GetEnvPtr(epval, epenv);
SET_THROWOBJ_CATCH_POINT(errinfo, (VALUE)(epenv->env + epenv->local_size));
}
}
}
rb_vm_rewrite_ep_in_errinfo(th, cfp->ep[-2]); /* #$! */
}
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
}
vm_core.h
rb_control_frame_t *rb_vm_get_binding_creatable_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp);
int rb_vm_get_sourceline(const rb_control_frame_t *);
VALUE rb_name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method);
void rb_vm_rewrite_ep_in_errinfo(rb_thread_t *th, VALUE errinfo);
void rb_vm_stack_to_heap(rb_thread_t *th);
void ruby_thread_init_stack(rb_thread_t *th);
int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp);
vm_trace.c
if (state) goto terminate;
th->errinfo = errinfo;
rb_vm_rewrite_ep_in_errinfo(th, th->errinfo);
}
terminate:
th->trace_arg = 0;
(1-1/2)