From 4341012c670df5ad59ab9c7ddf3b56924c8c324a Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 5 Apr 2021 12:10:38 +0200 Subject: thread_info: Fix crash when requesting for thread that never ran * kern/thread.c (thread_info): Set last_processor to 0 when the thread never ran. --- kern/thread.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kern/thread.c b/kern/thread.c index dfc6ff68..903fb559 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -1613,10 +1613,11 @@ kern_return_t thread_info( sched_info->depress_priority = thread->depress_priority; #if NCPUS > 1 - sched_info->last_processor = thread->last_processor->slot_num; -#else - sched_info->last_processor = 0; + if (thread->last_processor) + sched_info->last_processor = thread->last_processor->slot_num; + else #endif + sched_info->last_processor = 0; thread_unlock(thread); splx(s); -- cgit v1.2.3