Fix nil deref, swallowed cache read errors and log truncation cap#821
Merged
Conversation
Contributor
Author
ExecuteNewCall returns a nil instance on instantiation failure; closing it unconditionally panicked and masked the real error.
Get errors were checked after the found flag, so corrupt cache reads were silently treated as absent blocks.
ReachedLogsMaxByteCount compared against the 512 KiB per-message cap, truncating logs 10x earlier than documented.
sduchesneau
force-pushed
the
fix/engine-cache-wasm-bugs
branch
from
July 16, 2026 18:19
4d2ed92 to
a2ff4f3
Compare
Fixing the total-cap comparison bug (previous commit) now lets logs grow up to the intended 5 MiB, 10x bigger than what was actually enforced before. Cap at 2 MiB instead to keep output size close to current behavior.
sduchesneau
marked this pull request as ready for review
July 16, 2026 20:37
maoueh
approved these changes
Jul 16, 2026
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.
Fixes three confirmed bugs in the engine/cache/wasm paths.
Fixes
pipeline/exec/sharedcache.go—SharedCache.Executecalledinst.Close(ctx)before checking the error fromExecuteNewCall. The wazero runtime returns(nil, err)on instantiation or heap-write failure, so the nil interface dereference panicked in the tier1 shared-cache path and was recovered upstream as a generic "unknown error", masking the real cause. Now only closes a non-nil instance so the real error propagates.pipeline/cache/engine.go—Engine.NewBuffercheckedif !ok { continue }beforeif err != nil.fileReader.Getreturns(nil, false, err)on read errors, so corrupt/failed execout cache reads were silently treated as "block absent", producing silent data gaps instead of a failure. The error check now comes first.wasm/call.go—ReachedLogsMaxByteCountcompared the cumulativeLogsByteCountagainstmaxLogByteCount(512 KiB per-message cap) instead ofmaxTotalLogsByteCount, truncating module logs 10x earlier than the truncation message itself claims. Fixed the comparison to use the total cap — and, since that alone would let logs grow up to the constant's previous value of 5 MiB (10x more output than what was actually ever enforced), loweredmaxTotalLogsByteCountitself to 2 MiB so total log volume stays close to today's real-world behavior instead of jumping up.Tests
pipeline/exec/sharedcache_test.go— fakewasm.ModulewhoseExecuteNewCallreturns(nil, err):Executemust return the error without panicking.pipeline/cache/engine_test.go— fakeexecout.FileReader: a read error must failNewBuffer; absent blocks are still skipped; found payloads are still loaded into the buffer.wasm/call_logs_test.go— cumulative logs above 512 KiB but below 2 MiB must not be truncated; logs reaching 2 MiB must be truncated with the marker message.All new tests fail on the unfixed code and pass after the fixes. Full
go test ./pipeline/... ./wasm/...passes.🤖 Generated with Claude Code