fix: free WASM guest request allocation in host functions#369
Merged
Conversation
The wasm_msg_host_current_time host function receives a request pointer from the WASM guest but never frees it, leaking ~20 bytes per resolve_flags/apply_flags call. Over days this causes unbounded WASM linear memory growth. Fix by consuming the request pointer in Go, JS, and Python host functions. Java was already correct. Add WASM memory regression tests for all four providers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4 tasks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Align Go, JS, and Python host function plumbing with Java's pattern: - consumeRequest: read + decode + free the wasm-msg Request envelope - transferResponseSuccess: wrap data in a wasm-msg Response and transfer - transferResponseError: wrap error in a wasm-msg Response and transfer Host functions now use the same consume→handle→transfer pattern across all providers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wasm_msg_host_current_timehost function never frees the request pointer allocated by the WASM guestresolve_flags/apply_flagscall leaked ~20 bytes of WASM linear memory (which can only grow, never shrink)Test plan
TestWasmMemoryStableOnRepeatedResolveCalls— 50k resolves, zero memory growthwasm memory stability— 50k resolves, zero memory growthtest_multiple_resolves_dont_leak_memory— 50k resolves, zero memory growthwasmMemoryStableOnRepeatedResolveCalls— 50k resolves, zero memory growth🤖 Generated with Claude Code