Skip to content

Commit 7a3ff32

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 <judecn@gmail.com> Co-authored-by: Reagan Bohan <xbjfk.github@gmail.com>
1 parent 4795296 commit 7a3ff32

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stacker"
3-
version = "0.1.20"
3+
version = "0.1.21"
44
edition = "2021"
55
rust-version = "1.63"
66
authors = ["Alex Crichton <alex@alexcrichton.com>", "Simonas Kazlauskas <stacker@kazlauskas.me>"]

src/lib.rs

Lines changed: 1 addition & 1 deletion
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)