From a30401d8b1606163339185ea360f97ac7748e9f2 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sun, 19 Apr 2026 20:17:05 +0100 Subject: [PATCH] syscall: task: fix task_duplicate not taking a reference to the new task's address space --- syscall/task.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/syscall/task.c b/syscall/task.c index e164d44..ee3395d 100644 --- a/syscall/task.c +++ b/syscall/task.c @@ -540,18 +540,19 @@ kern_status_t sys_task_duplicate( return status; } - schedule_thread_on_cpu(new_thread); - child_handle_slot->h_object = &new_task->t_base; - space_handle_slot->h_object = &new_task->t_address_space->s_base; + space_handle_slot->h_object + = object_ref(&new_task->t_address_space->s_base); task_unlock_irqrestore(self, flags); - *out_task = child_handle; - *out_address_space = space_handle; - /* clear TLB */ pmap_switch(self->t_pmap); put_current_task(self); + *out_task = child_handle; + *out_address_space = space_handle; + + schedule_thread_on_cpu(new_thread); + return KERN_OK; }