Skip to content

Commit

Permalink
Fix stack_low detection when data_end is above stack_pointer and stac…
Browse files Browse the repository at this point in the history
…k_lower is missing
  • Loading branch information
Arshia001 authored and theduke committed Jul 16, 2024
1 parent 0b28230 commit 78e1f82
Showing 1 changed file with 8 additions and 1 deletion.
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 {
0
} else {
data_end
}
} else {
// clang-16 and higher generate the `__stack_low` global, and it can be exported with
Expand Down

0 comments on commit 78e1f82

Please sign in to comment.