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 issue with emscripten memory out of range #698

Merged
merged 1 commit into from
Aug 19, 2019

Conversation

bjfish
Copy link
Contributor

@bjfish bjfish commented Aug 19, 2019

Fixes #678

Some((
align_memory(*dynamic_base as u32 - 32),
align_memory(*dynamictop_ptr as u32 - 32),
))
Copy link
Contributor Author

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.

Copy link
Contributor

@MarkMcCaskey MarkMcCaskey left a 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.

@bjfish
Copy link
Contributor Author

bjfish commented Aug 19, 2019

bors r+

bors bot added a commit that referenced this pull request Aug 19, 2019
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);
Copy link
Contributor

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

@bors bors bot merged commit 1886760 into master Aug 19, 2019
@bors bors bot deleted the feature/fix-emscripten-memory-setup branch August 19, 2019 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants