ToscaLorno opened PR #15092 from ToscaLorno:fix/component-model-async-error-context-refcount to bytecodealliance:main:
Summary
Fixes bytecodealliance/wasmtime#14674.
When an
error-contexthandle is transferred across component instances via an async future or stream, lowering it into the recipient instance inserts a local handle entry pointing to the underlying global error context table. However,lower_error_context_to_indexpreviously omitted incrementing the cross-subcomponentglobal_ref_count.As a consequence, when the recipient instance subsequently invoked
error-context.drop, the global reference count was decremented to zero prematurely, deleting the global error context tracking while the sending instance still retained its handle.This patch updates
lower_error_context_to_indexto increment the global reference count on insertion, mirroring the semantics oferror_context_transfer.Testing
Added regression test
tests/misc_testsuite/component-model/async/error-context-future.wast, verifying that dropping the received error-context in a recipient instance does not invalidate or break subsequent drops in the sender.Ran test suite:
cargo test --test wast error-context-future: PASS (CraneliftNative + Winch)cargo test --test wast async: 266 passed; 0 failed; 0 ignored
ToscaLorno removed the review request for wasmtime-core-reviewers from PR #15092.
ToscaLorno requested pchickey for a review on PR #15092.
ToscaLorno requested wasmtime-core-reviewers for a review on PR #15092.
github-actions[bot] added the label wasmtime:api on PR #15092.
alexcrichton commented on PR #15092:
Thanks for the PR, but I'm personally hesitant to try to fixup error-context piecemeal like this. I know LLMs are good at generating code, but the prompt here of "fix the bug" I feel is not complete enough. The error-context type is pretty under-baked right now and likely needs some deeper redesign. The logged issues we have are an attempt to catalogue known issues with it but I wouldn't recommend new contributors try to take them on
ToscaLorno commented on PR #15092:
Thanks for the context @alexcrichton! Completely makes sense that
error-contextneeds a deeper architectural overhaul rather than piecemeal localized fixes. Appreciate your time and insight!
ToscaLorno commented on PR #15092:
Closing this PR per the discussion above to leave space for the broader architectural redesign of error-context. Thanks again @alexcrichton!
:cross_mark: ToscaLorno closed without merge PR #15092.
Last updated: Oct 31 2026 at 23:03 UTC