-
Notifications
You must be signed in to change notification settings - Fork 1.8k
wasi: do not panic on extreme file timestamps in DescriptorStat #13894
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
alexcrichton
merged 7 commits into
bytecodealliance:main
from
SebTardif:fix/datetime-from-no-unwrap
Jul 20, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
18709e9
wasi: do not panic on extreme file timestamps in DescriptorStat
SebTardif a260e1b
wasi: rustfmt import order in filesystem.rs
SebTardif 4a8cd69
wasi: address review on DescriptorStat timestamp conversion
SebTardif d318180
wasi: exercise extreme host mtime via guest filestat
SebTardif 7c8be00
wasi: share extreme-mtime fixture and dedupe test runners
SebTardif 271bcef
wasi: make extreme-mtime fixture constructible on Windows
SebTardif abc8b06
wasi: rustfmt extreme_host_mtime fixture
SebTardif File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
crates/test-programs/src/bin/p1_stat_extreme_host_mtime.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #![expect(unsafe_op_in_unsafe_fn, reason = "old code, not worth updating yet")] | ||
|
|
||
| use std::{env, process}; | ||
| use test_programs::preview1::open_scratch_directory; | ||
|
|
||
| const FILENAME: &str = "extreme.dat"; | ||
| const EXPECTED: &[u8] = b"hello"; | ||
|
|
||
| unsafe fn test_stat_extreme_host_mtime(dir_fd: wasip1::Fd) { | ||
| let st = wasip1::path_filestat_get(dir_fd, 0, FILENAME).expect("path_filestat_get"); | ||
| assert_eq!(st.size, EXPECTED.len() as u64, "size"); | ||
| let _ = st.mtim; | ||
| let _ = st.atim; | ||
|
|
||
| let fd = | ||
| wasip1::path_open(dir_fd, 0, FILENAME, 0, wasip1::RIGHTS_FD_READ, 0, 0).expect("path_open"); | ||
| let mut buf = [0u8; 16]; | ||
| let nread = wasip1::fd_read( | ||
| fd, | ||
| &[wasip1::Iovec { | ||
| buf: buf.as_mut_ptr(), | ||
| buf_len: buf.len(), | ||
| }], | ||
| ) | ||
| .expect("fd_read"); | ||
| assert_eq!(&buf[..nread], EXPECTED, "contents"); | ||
| wasip1::fd_close(fd).expect("fd_close"); | ||
| } | ||
|
|
||
| fn main() { | ||
| let mut args = env::args(); | ||
| let prog = args.next().unwrap(); | ||
| let arg = if let Some(arg) = args.next() { | ||
| arg | ||
| } else { | ||
| eprintln!("usage: {prog} <scratch directory>"); | ||
| process::exit(1); | ||
| }; | ||
|
|
||
| let dir_fd = match open_scratch_directory(&arg) { | ||
| Ok(dir_fd) => dir_fd, | ||
| Err(err) => { | ||
| eprintln!("{err}"); | ||
| process::exit(1); | ||
| } | ||
| }; | ||
|
|
||
| unsafe { test_stat_extreme_host_mtime(dir_fd) } | ||
| } |
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.