mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
ps: fix stack freeing bug
The thread could still be running on its stack whenever the stack ends up getting reaped, which would free and reuse the stack before it stops being used. Lock and unlock the thread to wait until it finishes switching.
This commit is contained in:
@@ -25,6 +25,11 @@ fn reap_thread(obj: *anyopaque, _: ?*anyopaque) void {
|
||||
// Bleh
|
||||
const entry: *rtl.List.Entry = @fieldParentPtr("next", link);
|
||||
const ketd: *ke.Thread = @fieldParentPtr("runq_link", entry);
|
||||
|
||||
// Wait until the thread finishes switching off its stack.
|
||||
const ipl = ketd.lock.acquire();
|
||||
ketd.lock.release(ipl);
|
||||
|
||||
const td: *Thread = @fieldParentPtr("kern", ketd);
|
||||
|
||||
psp.turnstile_zone.destroy(td.kern.turnstile);
|
||||
|
||||
Reference in New Issue
Block a user