Skip to content

Instantly share code, notes, and snippets.

@shugo
Created September 1, 2010 03:00
Show Gist options
  • Save shugo/560157 to your computer and use it in GitHub Desktop.
Save shugo/560157 to your computer and use it in GitHub Desktop.
diff --git a/vm.c b/vm.c
index b4d0f39..949fdb6 100644
--- a/vm.c
+++ b/vm.c
@@ -69,7 +69,7 @@ static inline VALUE
rb_vm_set_finish_env(rb_thread_t * th)
{
vm_push_frame(th, 0, VM_FRAME_MAGIC_FINISH,
- Qnil, rb_cObject, th->cfp->lfp[0], 0,
+ Qnil, Qnil, th->cfp->lfp[0], 0,
th->cfp->sp, 0, 1);
th->cfp->pc = (VALUE *)&finish_insn_seq[0];
return Qtrue;
@@ -1800,7 +1800,7 @@ th_init2(rb_thread_t *th, VALUE self)
th->cfp = (void *)(th->stack + th->stack_size);
- vm_push_frame(th, 0, VM_FRAME_MAGIC_TOP, Qnil, rb_cObject, 0, 0,
+ vm_push_frame(th, 0, VM_FRAME_MAGIC_TOP, Qnil, Qnil, 0, 0,
th->stack, 0, 1);
th->status = THREAD_RUNNABLE;
diff --git a/vm_eval.c b/vm_eval.c
index 0c5fc5a..374a999 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -163,7 +163,7 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv)
rb_method_entry_t *me;
rb_control_frame_t *cfp = th->cfp;
- if (!cfp->iseq) {
+ if (!cfp->iseq && !NIL_P(cfp->klass)) {
klass = RCLASS_SUPER(cfp->klass);
if (klass == 0) {
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 8fedb25..4bdf94c 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -65,7 +65,13 @@ vm_push_frame(rb_thread_t * th, const rb_iseq_t * iseq,
cfp->klass = klass;
}
else {
- cfp->klass = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)->klass;
+ rb_control_frame_t *prev_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
+ if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, prev_cfp)) {
+ cfp->klass = Qnil;
+ }
+ else {
+ cfp->klass = prev_cfp->klass;
+ }
}
#define COLLECT_PROFILE 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment