Skip to content

Conversation

sashass1315
Copy link
Contributor

Problem: In write_json_gzip_file, after GzEncoder::finish() we did not flush the inner BufWriter. Errors on the final buffered write can be silently ignored in Drop, causing undetected partial writes or I/O failures.

Why: BufWriter does not report errors on Drop. Without an explicit flush(), final write errors are lost. Additionally, we mapped finish() errors to WriteJson (serde) instead of I/O.

Fix: Capture the inner writer from finish() and call flush() on it. Map both finish() and flush() errors via FsPathError::write to provide correct path-contextual I/O errors.

Context: This gzip-to-disk path is only used by evm::executors::corpus when corpus_gzip is enabled. Other gzip usage (anvil state dump) targets Vec and doesn’t require flush(). Non-gzip JSON writers already call flush() explicitly.

@onbjerg onbjerg self-assigned this Sep 29, 2025
@onbjerg onbjerg merged commit c40bd19 into foundry-rs:master Sep 29, 2025
16 checks passed
@github-project-automation github-project-automation bot moved this to Done in Foundry Sep 29, 2025
@grandizzy grandizzy moved this from Done to Completed in Foundry Sep 29, 2025
@sashass1315 sashass1315 deleted the fix/fs-write_json_gzip-flush branch October 2, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

2 participants