sim(storage): a truncation that overtakes a delayed read completes as InvalidInput instead of a short read

Open
#256 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend, testing

Research direction

Start by tracing the read submission and completion paths in crates/moonpool-sim/src/storage/file.rs:106 and crates/moonpool-sim/src/storage/sim/engine.rs:1217, then inspect FileImage::read in crates/moonpool-sim/src/storage/image.rs:241. Add ordered two-handle tests for partial truncation and truncation below the read offset across stream and positioned reads. Done means truncation produces a short read or EOF rather than InvalidInput, with the effective fault range and stream-cursor advance handled.

Written by the indexing model from the issue text.

Description

bug simulation

Found during the pre-release source audit of 8d9e779 (read-only, nothing compiled or run). Severity: medium. Status: plausible (path traced, not reproduced).

Where

  • crates/moonpool-sim/src/storage/file.rs:106 (read length clamped at submission)
  • crates/moonpool-sim/src/storage/sim/engine.rs:1217 (completion reads pending.len)
  • crates/moonpool-sim/src/storage/image.rs:241 (FileImage::read rejects any range past EOF with InvalidInput)

What

Simulated reads clamp their length when submitted. If another handle truncates the file before the delayed read completes, completion still uses the old length and FileImage::read returns InvalidInput because the range now runs past EOF. The caller sees a storage error that no injected fault explains.

Proposed fix

Reconcile the read length with the current EOF at completion (including the effective fault range and stream-cursor advance) and return a short read or EOF. Add ordered two-handle tests for partial truncation and truncation below the read offset, for both stream and positioned reads.

Dominant language
Rust
Stars
49
Forks
3
Avg merge
1h 4m
Merged PRs (30d)
41

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PierreZ/moonpool

All issues in PierreZ/moonpool

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.