Skip to content

non-deterministically truncate reads/writes #4481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2025

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Jul 19, 2025

Fixes #4369: with 50% chance, we only read/write half the requested buffer. This quickly found some issues in our test suite.^^

@rustbot
Copy link
Collaborator

rustbot commented Jul 19, 2025

Thank you for contributing to Miri!
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Jul 19, 2025
@RalfJung RalfJung changed the title Read write truncate non-deterministically truncate reads/writes Jul 19, 2025
@RalfJung RalfJung force-pushed the read-write-truncate branch 2 times, most recently from 0ca00b3 to 1f45810 Compare July 19, 2025 13:21
@RalfJung RalfJung force-pushed the read-write-truncate branch from 1f45810 to e876589 Compare July 19, 2025 13:39
@RalfJung RalfJung enabled auto-merge July 19, 2025 13:43
@RalfJung RalfJung force-pushed the read-write-truncate branch from e876589 to da73151 Compare July 19, 2025 13:53
@@ -462,6 +463,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
};
let io_status_info = this.project_field_named(&io_status_block, "Information")?;

// It seems like short writes are not a thing on Windows, so we don't truncate `count` here.
// FIXME: if we are on a Unix host, short host writes host are visible to the program!
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CraftSpider is it correct that partial reads/writes are not a thing on Windows?
https://stackoverflow.com/questions/62438021/can-ntreadfile-produce-a-short-read-without-reaching-eof seems fairly clear here.

OTOH that also says that io_status_info would not be written on failure, whereas we always reset it to 0...

@RalfJung RalfJung force-pushed the read-write-truncate branch from da73151 to 2d40089 Compare July 19, 2025 13:54
@RalfJung RalfJung disabled auto-merge July 19, 2025 13:55
@RalfJung RalfJung force-pushed the read-write-truncate branch 3 times, most recently from 0748566 to 419c263 Compare July 19, 2025 16:10
@RalfJung RalfJung force-pushed the read-write-truncate branch from 419c263 to b1a308b Compare July 19, 2025 16:43
@oli-obk oli-obk added this pull request to the merge queue Jul 21, 2025
Merged via the queue into rust-lang:master with commit 9396463 Jul 21, 2025
13 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Waiting for a review to complete label Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Miri should artifically shorten some reads/writes
3 participants