fix gc bug: ci->env and env-up are nullable

This commit is contained in:
Yuichi Nishiwaki 2013-10-29 16:39:57 +09:00
parent 787dae1fe5
commit 35bbd66812
2 changed files with 7 additions and 2 deletions

View File

@ -162,7 +162,9 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
for (i = 0; i < env->num_val; ++i) { for (i = 0; i < env->num_val; ++i) {
gc_mark(pic, env->values[i]); gc_mark(pic, env->values[i]);
} }
if (env->up) {
gc_mark_object(pic, (struct pic_object *)env->up); gc_mark_object(pic, (struct pic_object *)env->up);
}
break; break;
} }
case PIC_TT_PROC: { case PIC_TT_PROC: {
@ -222,8 +224,10 @@ gc_mark_phase(pic_state *pic)
/* callinfo */ /* callinfo */
for (ci = pic->ci; ci != pic->cibase; --ci) { for (ci = pic->ci; ci != pic->cibase; --ci) {
if (ci->env) {
gc_mark_object(pic, (struct pic_object *)ci->env); gc_mark_object(pic, (struct pic_object *)ci->env);
} }
}
/* arena */ /* arena */
for (i = 0; i < pic->arena_idx; ++i) { for (i = 0; i < pic->arena_idx; ++i) {

View File

@ -317,6 +317,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
ci->argc = pc->u.i; ci->argc = pc->u.i;
ci->pc = pc; ci->pc = pc;
ci->fp = pic->sp - pc->u.i; ci->fp = pic->sp - pc->u.i;
ci->env = NULL;
if (pic_proc_cfunc_p(c)) { if (pic_proc_cfunc_p(c)) {
v = proc->u.cfunc(pic); v = proc->u.cfunc(pic);
pic->sp = ci->fp; pic->sp = ci->fp;