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

[WASM] Fix bug where we try to set more memory on WASM heap than malloc'd #2591

Merged
merged 2 commits into from
Dec 19, 2019

Conversation

nsthorat
Copy link
Contributor

@nsthorat nsthorat commented Dec 19, 2019

If a values TypedArray is passed to the WASM backend we:

  1. malloc bytes based on the shape, dtype
  2. set the buffer based on the values buffer size.

However, the values buffer size could not match the size of the values array itself because values can be a view of a larger buffer (e.g. with Array.subarray()).

This makes sure we only set into the WASM heap the number of bytes we've actually malloc'd.

The unit test I wrote to catch this is now in core (as all backends need this to be true) and I verified it crashes the page without the fix.


This change is Reviewable

Copy link
Contributor

@dsmilkov dsmilkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r1.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @dsmilkov)

Copy link
Contributor

@dsmilkov dsmilkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing find by the way!!

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @dsmilkov)

@nsthorat nsthorat merged commit e85c00f into master Dec 19, 2019
@nsthorat nsthorat deleted the malloc branch December 19, 2019 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants