Skip to content
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

Support DirEntry metadata calls in miri #103075

Merged
merged 1 commit into from
Oct 18, 2022
Merged

Conversation

SUPERCILEX
Copy link
Contributor

@SUPERCILEX SUPERCILEX commented Oct 15, 2022

This should work as it uses lstat64 which is supported here: https://github.com/rust-lang/miri/blob/d9ad25ee4bbd9364c498959cdc82b5fa6c41e63c/src/shims/unix/macos/foreign_items.rs#L42 just noticed that's macos, linux would be using statx: https://github.com/rust-lang/miri/blob/86f0e63b21721fe2c14608644f467b9cb21945eb/src/shims/unix/linux/foreign_items.rs#L112

The failing syscall is dirfd, so maybe that should actually be added to the shims?

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Oct 15, 2022
@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot
Copy link
Collaborator

rustbot commented Oct 15, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 15, 2022
@SUPERCILEX
Copy link
Contributor Author

r? @RalfJung

@RalfJung
Copy link
Member

I can't approve miri-specific library hacks, that needs someone from the libs team.
Cc @thomcc

However, from the Miri side, this is lacking tests that ensure that this actually works.

The failing syscall is dirfd, so maybe that should actually be added to the shims?

The problem is that dirfd is not exposed by the standard library, so Miri has no good way of implementing that shim in a cross-platform way.

@thomcc
Copy link
Member

thomcc commented Oct 15, 2022

r? @thomcc

@rust-highfive rust-highfive assigned thomcc and unassigned RalfJung Oct 15, 2022
@thomcc
Copy link
Member

thomcc commented Oct 15, 2022

The problem is that dirfd is not exposed by the standard library, so Miri has no good way of implementing that shim in a cross-platform way.

This would bother me more if we didn't already have both code-paths -- maintaining the miri in the cfg does not worry me.

It is unfortunate from the perspective of having slightly inaccurate emulation on these targets, though.

However, from the Miri side, this is lacking tests that ensure that this actually works.

Hmm, this is a good point I guess. Would adding a test for this function in libstd be sufficient here?

@RalfJung
Copy link
Member

Which libstd API function is enabled by this? The test should be added in src/tools/miri/tests/pass-dep/shims/fs.rs.

@thomcc
Copy link
Member

thomcc commented Oct 16, 2022

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 16, 2022
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@rustbot
Copy link
Collaborator

rustbot commented Oct 16, 2022

The Miri subtree was changed

cc @rust-lang/miri

@SUPERCILEX
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 16, 2022
@thomcc
Copy link
Member

thomcc commented Oct 16, 2022

Thanks. Looks good to me if @RalfJung doesn't want any changes to the tests.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 18, 2022

@bors r=thomcc

Looks good to me

@bors
Copy link
Contributor

bors commented Oct 18, 2022

📌 Commit 7273358 has been approved by thomcc

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 18, 2022
@bors
Copy link
Contributor

bors commented Oct 18, 2022

⌛ Testing commit 7273358 with merge 21b2465...

@bors
Copy link
Contributor

bors commented Oct 18, 2022

☀️ Test successful - checks-actions
Approved by: thomcc
Pushing 21b2465 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 18, 2022
@bors bors merged commit 21b2465 into rust-lang:master Oct 18, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 18, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (21b2465): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.7%, -2.2%] 2
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Footnotes

  1. the arithmetic mean of the percent change

  2. number of relevant changes

@SUPERCILEX SUPERCILEX deleted the miri-metadata branch October 18, 2022 19:26
@@ -404,6 +404,14 @@ fn test_directory() {
let mut file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>();
file_names.sort_unstable();
assert_eq!(file_names, vec!["test_file_1", "test_file_2"]);
// Test that read_dir metadata calls succeed
assert_eq!(
&[true, true],
Copy link
Member

@RalfJung RalfJung Oct 19, 2022

Choose a reason for hiding this comment

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

Ideally we'd also make sure it returns false on directories.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, created #103258

Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
Support DirEntry metadata calls in miri

This should work as it uses lstat64 which is supported here: ~https://github.com/rust-lang/miri/blob/d9ad25ee4bbd9364c498959cdc82b5fa6c41e63c/src/shims/unix/macos/foreign_items.rs#L42~ just noticed that's macos, linux would be using statx: https://github.com/rust-lang/miri/blob/86f0e63b21721fe2c14608644f467b9cb21945eb/src/shims/unix/linux/foreign_items.rs#L112

The failing syscall is `dirfd`, so maybe that should actually be added to the shims?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants