Skip to content

fix(go): prevent silent crash during concurrent WASM recovery - #515

Closed
fabriziodemaria wants to merge 1 commit into
mainfrom
fdema/go-recovery-concurrency-fix
Closed

fix(go): prevent silent crash during concurrent WASM recovery#515
fabriziodemaria wants to merge 1 commit into
mainfrom
fdema/go-recovery-concurrency-fix

Conversation

@fabriziodemaria

Copy link
Copy Markdown
Member

Summary

  • Serialize RecoveringResolver operations with a mutex so WASM instance recreation cannot close an instance while another resolve is still running on it.
  • Perform recreation synchronously while the mutex is held, instead of swapping/closing in a background goroutine during concurrent pool resolves.
  • Never cache or return nil WASM export handles; panic with a descriptive error so withRecover turns follow-on failures into evaluation errors instead of silent process death.

Motivation

When a WASM guest trap triggers recovery, the old wazero instance was closed in a background goroutine while another resolve on the same pooled slot could still be mid-call. Module.ExportedFunction on a closed instance returns nil, which was cached in fnCache and later dereferenced — producing exit code 139 with no Go traceback.

Test plan

  • go test ./confidence/internal/local_resolver/... -run 'RecoveringResolver|ExportedFunction'
  • go build ./...
  • Deploy alongside interpreter-mode fix or independently and monitor temporal-worker SIGSEGV rate

Related

Made with Cursor

Hold a mutex across RecoveringResolver operations so recreation cannot
close a WASM instance while another resolve is in flight. Panic instead
of caching nil WASM function handles so recovery converts silent process
death into a handled evaluation error.
@fabriziodemaria
fabriziodemaria marked this pull request as ready for review August 11, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant