Skip to content

Commit

Permalink
Account for stack_lower being above stack_higher
Browse files Browse the repository at this point in the history
  • Loading branch information
Arshia001 committed May 9, 2024
1 parent 4fa2687 commit a7ba703
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/wasix/src/state/func_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl WasiFunctionEnv {
));
}

let stack_lower = if let Some(stack_low) = stack_low {
let mut stack_lower = if let Some(stack_low) = stack_low {
match stack_low.get(store) {
wasmer::Value::I32(a) => a as u64,
wasmer::Value::I64(a) => a as u64,
Expand All @@ -203,6 +203,14 @@ impl WasiFunctionEnv {
0
};

if stack_lower >= stack_base {
tracing::warn!(
"Detected lower end of stack to be above higher end, ignoring stack_lower; \
unwinding may cause memory corruption"
);
stack_lower = 0;
}

// Update the stack layout which is need for asyncify
let env = self.data_mut(store);
let tid = env.tid();
Expand Down

0 comments on commit a7ba703

Please sign in to comment.