-
Notifications
You must be signed in to change notification settings - Fork 824
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 issue with emscripten memory out of range #698
Conversation
Some(( | ||
align_memory(*dynamic_base as u32 - 32), | ||
align_memory(*dynamictop_ptr as u32 - 32), | ||
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In development profile, there was a subtraction underflow before the index out of bounds error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from a quick look over;
General comment: I think we should move away from memory.view::<u32>()[(dynamictop_ptr / 4) as usize]
in favor of the WasmPtr abstraction. WasmPtr
handles a lot of the complexity and avoids us having to do division and manual alignment checks.
bors r+ |
698: Fix issue with emscripten memory out of range r=bjfish a=bjfish Fixes #678 Co-authored-by: Brandon Fish <[email protected]>
let dynamictop_ptr = globals.dynamictop_ptr; | ||
let dynamic_base = globals.dynamic_base; | ||
|
||
if (dynamictop_ptr / 4) as usize >= memory.view::<u32>().len() { | ||
return Err("dynamictop_ptr beyond memory len".to_string()); | ||
} | ||
memory.view::<u32>()[(dynamictop_ptr / 4) as usize].set(dynamic_base); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very tired, so I kind of missed this, but the bounds check here is something WasmPtr
would have done for us and this is kind of new legacy code that we should probably just do right... I suppose I can replace it once this lands on master though
Fixes #678