Fix use after free bug in vvp when a task or function is disabled.

Use test_joinable() and do_join() to ensure everything gets cleaned
up before the thread is reaped. This should fix br1016, br1017, and
br1018.

(cherry picked from commit 0bed890bc6)
(and subsequent fixup)
This commit is contained in:
Martin Whitaker 2017-09-17 19:48:54 +01:00
parent 7b372c3a0c
commit 885e25120a
1 changed files with 2 additions and 2 deletions

View File

@ -2200,7 +2200,7 @@ static bool do_disable(vthread_t thr, vthread_t match)
}
vthread_t parent = thr->parent;
if (parent && parent->i_am_joining) {
if (parent && parent->i_am_joining && test_joinable(parent, thr)) {
// If a parent is waiting in a %join, wake it up. Note
// that it is possible to be waiting in a %join yet
// already scheduled if multiple child threads are
@ -2210,7 +2210,7 @@ static bool do_disable(vthread_t thr, vthread_t match)
if (! parent->i_have_ended)
schedule_vthread(parent, 0, true);
// Let the parent do the reaping.
// do_join(parent, thr);
vthread_reap(thr);
} else if (parent) {