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

run alloc benchmarks in Miri and fix UB #104097

Merged
merged 2 commits into from
Nov 9, 2022

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Nov 7, 2022

Miri since recently has a "fake monotonic clock" that works even with isolation. Its measurements are not very meaningful but it means we can run these benches and check them for UB.

And that's a good thing since there was UB here: fixes #104096.

r? @thomcc

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 7, 2022
@rustbot
Copy link
Collaborator

rustbot commented Nov 7, 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-log-analyzer

This comment has been minimized.

Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

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

Mildly cursed but it's inside unit-testsbenches so, fine.

let mut deq = VecDeque::<i32>::with_capacity(size + 1);
// We'll mess with private state to pretend like `deq` is filled.
// Make sure the buffer is initialized so that we don't read uninit memory.
unsafe { deq.ptr().write_bytes(0u8, size + 1) };
Copy link
Member

Choose a reason for hiding this comment

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

🙀

Copy link
Member Author

Choose a reason for hiding this comment

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

Not more cursed than just setting the head and tail fields without doing this...

I considered creating a filled VecDeque from an array, but that seems to me like it'd make even more assumptions about internal implementation details...

@thomcc
Copy link
Member

thomcc commented Nov 8, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 8, 2022

📌 Commit 29d451c 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 Nov 8, 2022
Manishearth added a commit to Manishearth/rust that referenced this pull request Nov 8, 2022
run alloc benchmarks in Miri and fix UB

Miri since recently has a "fake monotonic clock" that works even with isolation. Its measurements are not very meaningful but it means we can run these benches and check them for UB.

And that's a good thing since there was UB here: fixes rust-lang#104096.

r? `@thomcc`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 8, 2022
…llaumeGomez

Rollup of 12 pull requests

Successful merges:

 - rust-lang#103928 (Add 'ty_error_with_guaranteed' and 'const_error_with_guaranteed')
 - rust-lang#104027 (Place config.toml in current working directory if config not found)
 - rust-lang#104093 (disable btree size tests on Miri)
 - rust-lang#104097 (run alloc benchmarks in Miri and fix UB)
 - rust-lang#104104 (Add split-debuginfo print option)
 - rust-lang#104109 (rustdoc: Add mutable to the description)
 - rust-lang#104113 (Fix `const_fn_trait_ref_impl`, add test for it)
 - rust-lang#104114 (Fix invalid background-image file name)
 - rust-lang#104132 (fix: lint against lint functions)
 - rust-lang#104139 (Clarify licensing situation of MPSC and SPSC queue)
 - rust-lang#104147 (Remove an address comparison from the parser)
 - rust-lang#104165 (Add llvm-main to triagebot.toml)

Failed merges:

 - rust-lang#104115 (Migrate crate-search element to CSS variables)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 53b6a89 into rust-lang:master Nov 9, 2022
@rustbot rustbot added this to the 1.67.0 milestone Nov 9, 2022
@RalfJung RalfJung deleted the miri-alloc-benches branch November 11, 2022 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

VecDeque benchmarks have UB
5 participants