From 62eab8a2fe9e0ccf735906bd191d2baaffd19a18 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Sun, 9 Apr 2023 12:04:08 +0200 Subject: [PATCH] Retry rather than panic if clone_entry is unset. --- src/scheme/proc.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/scheme/proc.rs b/src/scheme/proc.rs index b90b5d9e78..2d862ca1c8 100644 --- a/src/scheme/proc.rs +++ b/src/scheme/proc.rs @@ -1358,11 +1358,16 @@ impl KernelScheme for ProcScheme { extern "C" fn clone_handler() { let context_lock = Arc::clone(context::contexts().current().expect("expected the current context to be set in a spawn closure")); - unsafe { - let [ip, sp] = context_lock.read().clone_entry.expect("clone_entry must be set"); - let [arg, is_singlestep] = [0; 2]; + loop { + unsafe { + let Some([ip, sp]) = context_lock.read().clone_entry else { + context_lock.write().status = Status::Stopped(SIGSTOP); + continue; + }; + let [arg, is_singlestep] = [0; 2]; - crate::start::usermode(ip, sp, arg, is_singlestep); + crate::start::usermode(ip, sp, arg, is_singlestep); + } } }