kernel/thread: Free death entries if they aren't used.

Otherwise they will be leaked.

I added a dprintf() in this codepath, it happened a small number of
times on boot and when running a compile job.
This commit is contained in:
Augustin Cavalier
2025-03-03 14:15:05 -05:00
parent da6325cd03
commit 333274ddfb
+10 -5
View File
@@ -2268,12 +2268,17 @@ thread_exit(void)
} else {
// The thread is not the main thread. We store a thread death entry
// for it, unless someone is already waiting for it.
if (threadDeathEntry != NULL && thread->exit.waiters.IsEmpty()) {
threadDeathEntry->thread = thread->id;
threadDeathEntry->status = thread->exit.status;
if (threadDeathEntry != NULL) {
if (thread->exit.waiters.IsEmpty()) {
threadDeathEntry->thread = thread->id;
threadDeathEntry->status = thread->exit.status;
// add entry to dead thread list
team->dead_threads.Add(threadDeathEntry);
// add entry to dead thread list
team->dead_threads.Add(threadDeathEntry);
} else {
deferred_free(threadDeathEntry);
threadDeathEntry = NULL;
}
}
threadCreationLocker.Unlock();