Fix nil deref, swallowed cache read errors and log truncation cap#821
Draft
sduchesneau wants to merge 3 commits into
Draft
Fix nil deref, swallowed cache read errors and log truncation cap#821sduchesneau wants to merge 3 commits into
sduchesneau wants to merge 3 commits into
Conversation
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.
Contributor
Author
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(5 MiB total cap), truncating module logs 10x earlier than the truncation message itself claims. Now compares against the total cap.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 5 MiB must not be truncated; logs reaching 5 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