rust icon indicating copy to clipboard operation
rust copied to clipboard

Support DirEntry metadata calls in miri

Open SUPERCILEX opened this issue 1 year ago • 11 comments

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?

SUPERCILEX avatar Oct 15 '22 03:10 SUPERCILEX

r? @Mark-Simulacrum

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

rust-highfive avatar Oct 15 '22 03:10 rust-highfive

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

rustbot avatar Oct 15 '22 03:10 rustbot

r? @RalfJung

SUPERCILEX avatar Oct 15 '22 03:10 SUPERCILEX

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.

RalfJung avatar Oct 15 '22 06:10 RalfJung

r? @thomcc

thomcc avatar Oct 15 '22 06:10 thomcc

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?

thomcc avatar Oct 15 '22 06:10 thomcc

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

RalfJung avatar Oct 16 '22 07:10 RalfJung

@rustbot author

thomcc avatar Oct 16 '22 17:10 thomcc

The Miri subtree was changed

cc @rust-lang/miri

rustbot avatar Oct 16 '22 19:10 rustbot

@rustbot ready

SUPERCILEX avatar Oct 16 '22 19:10 SUPERCILEX

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

thomcc avatar Oct 16 '22 20:10 thomcc

@bors r=thomcc

Looks good to me

oli-obk avatar Oct 18 '22 10:10 oli-obk

:pushpin: Commit 727335878d316f6301780d182ea14ec4fb32531d has been approved by thomcc

It is now in the queue for this repository.

bors avatar Oct 18 '22 10:10 bors

:hourglass: Testing commit 727335878d316f6301780d182ea14ec4fb32531d with merge 21b246587c2687935bd6004ffa5dcc4f4dd6600d...

bors avatar Oct 18 '22 10:10 bors

:sunny: Test successful - checks-actions Approved by: thomcc Pushing 21b246587c2687935bd6004ffa5dcc4f4dd6600d to master...

bors avatar Oct 18 '22 13:10 bors

Finished benchmarking commit (21b246587c2687935bd6004ffa5dcc4f4dd6600d): 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.

mean[^1] range count[^2]
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.

[^1]: the arithmetic mean of the percent change [^2]: number of relevant changes

rust-timer avatar Oct 18 '22 18:10 rust-timer