diff options
author | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-12-18 09:13:34 +0100 |
---|---|---|
committer | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-12-18 09:13:34 +0100 |
commit | 94c521bf102a74aec7e1a5c3a9ef5eaa968d4e14 (patch) | |
tree | ad1ad80ee9a4e0ae97451c94a7cf455d3068951b /src/libthread | |
parent | 7cda34cf34f3afbd3f2000aa5e2b59ddc319f0f2 (diff) | |
parent | 2991442aef1cf020ffde43673433ee97ef322a53 (diff) | |
download | plan9port-94c521bf102a74aec7e1a5c3a9ef5eaa968d4e14.tar.gz plan9port-94c521bf102a74aec7e1a5c3a9ef5eaa968d4e14.tar.bz2 plan9port-94c521bf102a74aec7e1a5c3a9ef5eaa968d4e14.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/libthread')
-rw-r--r-- | src/libthread/thread.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 902942d9..65e65194 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -411,7 +411,14 @@ Top: p->nthread--; /*print("nthread %d\n", p->nthread); */ _threadstkfree(t->stk, t->stksize); - free(t); + /* + * Cannot free p->thread0 yet: it is used for the + * context switches back to the scheduler. + * Instead, we will free it at the end of this function. + * But all the other threads can be freed now. + */ + if(t != p->thread0) + free(t); } for(;;){ @@ -490,6 +497,7 @@ Out: unlock(&threadnproclock); unlock(&p->lock); _threadsetproc(nil); + free(p->thread0); free(p); _threadpexit(); } |