-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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][debugger] Fix reusing buffer for debugger #59773
Conversation
Tagging subscribers to this area: @thaystg Issue Details
|
This fix is appropriately minimal under the circumstances but it might make sense to inline the base64 decode here and avoid an intermediate copy. |
@kg any thoughts on a way to catch these more easily in testing? |
How was this caught, or how did it fail? |
caught in CTI testing, eventually if the runtime allocates more memory than the current allocation debugging will stop working (in fairly non-obvious ways) The underlying issue is emscripten-core/emscripten#12336 |
There's a suggestion in that issue to monkeypatch |
it is more a question of what exactly to do with those notifications |
The main problem is that in order to do anything about this we'd need to make people stop using raw arrayviews so we could wrap the views in a type that does something when the heap is invalidated. ArrayViews are designed to fail silently and weirdly in classic JS fashion, and because JS object indexing isn't customizable we can't even make a fake array-like object. We could do something like the root API and store the buffers in a container and make people call .value or .buffer every time, I suppose. I'm not sure that would help. In this case it would have at least. We probably just need to audit all our code for it - I thought I did in the past but I definitely did not see this line. |
But I'm not using Uint8Array to set the content on memory allocated using malloc as @lewing suggested in the same PR.
When the wasm linear memory has to grow it invalidates existing views into the heap. To avoid this issue make sure to always create a new view into the heap for the debugger command immediately before use.