Uh oh!
There was an error while loading. Please reload this page.
[wasm][debugger] Fix reusing buffer for debugger - #59773
Conversation
ghost
commented
Sep 29, 2021
Tagging subscribers to this area: @thaystg Issue Details
|
Uh oh!
There was an error while loading. Please reload this page.
lewing
commented
Sep 29, 2021
This fix is appropriately minimal under the circumstances but it might make sense to inline the base64 decode here and avoid an intermediate copy. |
lewing
commented
Sep 29, 2021
@kg any thoughts on a way to catch these more easily in testing? |
radical
commented
Sep 29, 2021
How was this caught, or how did it fail? |
lewing
commented
Sep 29, 2021
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 |
lambdageek
commented
Sep 29, 2021
There's a suggestion in that issue to monkeypatch |
lewing
commented
Sep 30, 2021
it is more a question of what exactly to do with those notifications |
kg
commented
Sep 30, 2021
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.