From: Jérémie Astor Date: Tue, 15 Dec 2020 00:18:52 +0000 (+0100) Subject: :bug: Fix Fork retval X-Git-Tag: nightly~1105^2~19 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=b2a298f64090a3c70567ef5cce7567a4001e1caa;p=gwion.git :bug: Fix Fork retval --- diff --git a/src/emit/emit.c b/src/emit/emit.c index a845a8f4..515654ce 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1342,7 +1342,7 @@ ANN static Instr spork_ini(const Emitter emit, const struct Sporker *sp) { const Func f = !sp->code ? sp->exp->d.exp_call.m_func : NULL; const Instr instr = emit_add_instr(emit, ForkIni); instr->m_val = (m_uint)sp->vm_code; - instr->m_val2 = f ? sp->type->size : 0; + instr->m_val2 = sp->type->size; return instr; } diff --git a/src/lib/lib_func.c b/src/lib/lib_func.c index 9fdeaa34..f9ff5cb2 100644 --- a/src/lib/lib_func.c +++ b/src/lib/lib_func.c @@ -291,6 +291,9 @@ ANN static Type fork_type(const Env env, const Exp_Unary* unary) { const Type fork = env->gwion->type[et_fork]; UNSET_FLAG(fork, final); const Type typed = str2type(env->gwion, "TypedFork", exp_self(unary)->pos); + // ensure room for retval + if(typed->nspc->info->offset == fork->nspc->info->offset) + typed->nspc->info->offset += t->size; UNSET_FLAG(typed, final); const Type ret = str2type(env->gwion, c, exp_self(unary)->pos); SET_FLAG(typed, final); diff --git a/src/lib/shred.c b/src/lib/shred.c index 25dcb175..60a20095 100644 --- a/src/lib/shred.c +++ b/src/lib/shred.c @@ -262,9 +262,10 @@ struct ThreadLauncher *tl = data; vm_run(vm); ++vm->bbq->pos; } - memcpy(me->data + vm->gwion->type[et_fork]->nspc->info->offset, *(m_bit**)ME(me)->reg, FORK_RETSIZE(me)); gwion_end_child(ME(me), vm->gwion); MUTEX_LOCK(vm->parent->shreduler->mutex); + if(!*(m_int*)(me->data + o_shred_cancel) && me->type_ref != vm->gwion->type[et_fork]) + memcpy(me->data + vm->gwion->type[et_fork]->nspc->info->offset, ME(me)->reg, FORK_RETSIZE(me)); *(m_int*)(me->data + o_fork_done) = 1; if(!*(m_int*)(me->data + o_shred_cancel)) broadcast(*(M_Object*)(me->data + o_fork_ev)); diff --git a/tests/error/abstract.gw b/tests/error/abstract.gw deleted file mode 100644 index 0252d6eb..00000000 --- a/tests/error/abstract.gw +++ /dev/null @@ -1,2 +0,0 @@ -#! [contains] is abstract, declare as ref -var Shred shred;