alexcrichton opened PR #12888 from alexcrichton:handle-pooled-deallocation-failure to bytecodealliance:main:
This commit replaces a few panics in the pooling allocator with error-handling of what happens at runtime. This is a defense-in-depth measure to ensure that the pooling allocator doesn't panic at runtime and instead handles errors where possible.
The first path fixed is in
deallocate_memorywhere resetting a slot could result in an error being returned on non-Linux platforms, and if this happened it would cause a panic. The error is instead gracefully handled by continuing slot deallocation but avoiding putting the image itself back into memory. This leaves the slot in anUnknownstate which is already handled by resetting the state upon reuse. The main consequence here is that future statistics about resident bytes won't be accurate, but these are already inaccurate on non-Linux platforms anyway, so there's no loss.The second path fixes is in flushing a
DecommitQueuewheredecommit_pageswas asserted to succeed. Instead now the error is handled by dropping all images and leaving slots in anUnknownstate, similar todeallocate_memory.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested cfallin for a review on PR #12888.
alexcrichton requested wasmtime-core-reviewers for a review on PR #12888.
github-actions[bot] added the label wasmtime:api on PR #12888.
cfallin submitted PR review.
cfallin created PR review comment:
Could we return a
Result<()>here and propagate the error? I know we won't use it in upper layers but it's still a bit more idiomatic IMHO. (Of course we can't use?inside because we still want to at least attempt all deallocations)Or if we really want the efficiency then
core::result::Result<(), ()>-- basically I don't want the ambiguity oftrue== success ortrue== failure...
alexcrichton updated PR #12888.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Good point yeah -- I changed this to
io::Result<()>to avoid boxing up awasmtime::Resultand it was pretty easy to handle, and looks better too!
alexcrichton has enabled auto merge for PR #12888.
alexcrichton added PR #12888 Handle more failures deallocating pooled memroy to the merge queue.
github-merge-queue[bot] removed PR #12888 Handle more failures deallocating pooled memroy from the merge queue.
alexcrichton added PR #12888 Handle more failures deallocating pooled memroy to the merge queue.
github-merge-queue[bot] removed PR #12888 Handle more failures deallocating pooled memroy from the merge queue.
alexcrichton added PR #12888 Handle more failures deallocating pooled memroy to the merge queue.
alexcrichton merged PR #12888.
alexcrichton removed PR #12888 Handle more failures deallocating pooled memroy from the merge queue.
Last updated: Apr 12 2026 at 23:10 UTC