From 8412d0d55f1c033146fae44dbcdf3aaa7d1005b9 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Mon, 9 Sep 2013 19:47:22 -0700 Subject: [PATCH] Automatic scope are OK in detached threads ...assuming certain conditions that should by definition be true. So this patch amounts to improving an assert condition. --- vvp/vthread.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vvp/vthread.cc b/vvp/vthread.cc index b9d3de756..b66928fe7 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -3110,8 +3110,11 @@ bool of_JOIN_DETACH(vthread_t thr, vvp_code_t cp) vthread_t child = *thr->children.begin(); assert(child->parent == thr); - // We cannot detach automatic tasks/functions - assert(child->wt_context == 0); + // We cannot detach automatic tasks/functions within an + // automatic scope. If we try to do that, we might make + // a mess of the allocation of the context. Note that it + // is OK if the child context is distinct (See %exec_ufunc.) + assert(child->wt_context==0 || thr->wt_context!=child->wt_context); if (child->i_have_ended) { // If the child has already ended, then reap it. vthread_reap(child);