Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stack_low detection when data_end is above stack_pointer and stac… #4925

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/wasix/src/state/func_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,17 @@ impl WasiFunctionEnv {
_ => 0,
}
} else if let Some(data_end) = data_end {
match data_end.get(store) {
let data_end = match data_end.get(store) {
wasmer::Value::I32(a) => a as u64,
wasmer::Value::I64(a) => a as u64,
_ => 0,
};
// It's possible for the data section to be above the stack, we check for that here and
// if it is, we'll assume the stack starts at address 0
if data_end >= stack_base {
theduke marked this conversation as resolved.
Show resolved Hide resolved
0
} else {
data_end
}
} else {
// clang-16 and higher generate the `__stack_low` global, and it can be exported with
Expand Down
Loading