From: Jakub Jirutka Date: Sat, 15 Jul 2023 21:29:34 +0200 Subject: [PATCH] Detect stack overflow in remaining_stack() See https://github.com/rust-lang/stacker/pull/51 --- a/vendor/stacker/src/lib.rs +++ b/vendor/stacker/src/lib.rs @@ -89,7 +89,12 @@ /// to determine whether a stack switch should be made or not. pub fn remaining_stack() -> Option { let current_ptr = current_stack_ptr(); - get_stack_limit().map(|limit| current_ptr - limit) + get_stack_limit().map(|limit| { + if current_ptr < limit { + panic!("stack overflow!"); + } + current_ptr - limit + }) } psm_stack_information! (