Skip to content

Commit f5c594c

Browse files
nagisajcnelsonxbjfk
committed
stacker: make remaining stack computation more resilient
Sounds like it is plausible for the stack pointer to end up past the computed stack limit depending on the implementation of stack growing and the exact timing at which the stack limit is determined. Supersedes #51 Co-authored-by: Jude Nelson <[email protected]> Co-authored-by: Reagan Bohan <[email protected]>
1 parent 681d10f commit f5c594c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn grow<R, F: FnOnce() -> R>(stack_size: usize, callback: F) -> R {
9191
/// to determine whether a stack switch should be made or not.
9292
pub fn remaining_stack() -> Option<usize> {
9393
let current_ptr = current_stack_ptr();
94-
get_stack_limit().map(|limit| current_ptr - limit)
94+
get_stack_limit().map(|limit| current_ptr.saturating_sub(limit))
9595
}
9696

9797
psm_stack_information!(

0 commit comments

Comments
 (0)