Commit Graph

210523 Commits

Author SHA1 Message Date
Ralf Jung
56a1d07cb7 prettify our CI logs 2022-11-26 14:53:10 +01:00
bors
4d3e565004 Auto merge of #2690 - Nilstrieb:cargo-miri-smoke-test-ci-so-that-cargo-miri-actually-works-kinda, r=RalfJung
Test a small cargo-miri smoke test even in `run_tests_minimal`

This makes sure that cargo-miri works on all targets.

Implements the first step of https://github.com/rust-lang/miri/pull/2685#issuecomment-1325155967 to get that PR tested.
2022-11-26 13:24:26 +00:00
Ralf Jung
166e60e2bb update lockfile 2022-11-26 14:16:45 +01:00
bors
7d0db1efdb Auto merge of #2647 - saethlin:current-span, r=RalfJung
Track local frames incrementally during execution

https://github.com/rust-lang/miri/pull/2646 currently introduces a performance regression. This change removes that regression, and provides a minor perf improvement.

The existing lazy strategy for tracking the span we want to display is as efficient as it is only because we often create a `CurrentSpan` then never call `.get()`. Most of the calls to the `before_memory_read` and `before_memory_write` hooks do not create any event that we store in `AllocHistory`. But data races are totally different, any memory read or write may race, so every call to those hooks needs to access to the current local span.

So this changes to a strategy where we update some state in a `Thread` and `FrameExtra` incrementally, upon entering and existing each function call.

Before:
```
Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/backtraces/Cargo.toml
  Time (mean ± σ):      5.532 s ±  0.022 s    [User: 5.444 s, System: 0.073 s]
  Range (min … max):    5.516 s …  5.569 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/mse/Cargo.toml
  Time (mean ± σ):     831.4 ms ±   3.0 ms    [User: 783.8 ms, System: 46.7 ms]
  Range (min … max):   828.7 ms … 836.1 ms    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/serde1/Cargo.toml
  Time (mean ± σ):      1.975 s ±  0.021 s    [User: 1.914 s, System: 0.059 s]
  Range (min … max):    1.939 s …  1.990 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/serde2/Cargo.toml
  Time (mean ± σ):      4.060 s ±  0.051 s    [User: 3.983 s, System: 0.071 s]
  Range (min … max):    3.972 s …  4.100 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/slice-get-unchecked/Cargo.toml
  Time (mean ± σ):     784.9 ms ±   8.2 ms    [User: 746.5 ms, System: 37.7 ms]
  Range (min … max):   772.9 ms … 793.3 ms    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/unicode/Cargo.toml
  Time (mean ± σ):      1.679 s ±  0.006 s    [User: 1.623 s, System: 0.055 s]
  Range (min … max):    1.673 s …  1.687 s    5 runs
```
After:
```
Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/backtraces/Cargo.toml
  Time (mean ± σ):      5.330 s ±  0.037 s    [User: 5.232 s, System: 0.084 s]
  Range (min … max):    5.280 s …  5.383 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/mse/Cargo.toml
  Time (mean ± σ):     818.9 ms ±   3.7 ms    [User: 776.8 ms, System: 41.3 ms]
  Range (min … max):   813.5 ms … 822.5 ms    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/serde1/Cargo.toml
  Time (mean ± σ):      1.927 s ±  0.011 s    [User: 1.864 s, System: 0.061 s]
  Range (min … max):    1.917 s …  1.945 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/serde2/Cargo.toml
  Time (mean ± σ):      3.974 s ±  0.020 s    [User: 3.893 s, System: 0.076 s]
  Range (min … max):    3.956 s …  4.004 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/slice-get-unchecked/Cargo.toml
  Time (mean ± σ):     780.0 ms ±   5.3 ms    [User: 740.3 ms, System: 39.0 ms]
  Range (min … max):   771.2 ms … 784.5 ms    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/unicode/Cargo.toml
  Time (mean ± σ):      1.643 s ±  0.007 s    [User: 1.584 s, System: 0.058 s]
  Range (min … max):    1.635 s …  1.654 s    5 runs
```
(This change is marginal, but the point is that it avoids a much more significant regression)
2022-11-26 13:02:15 +00:00
Ralf Jung
726b9d09d4 caller_span only makes sense when there are 2 frames on the stack 2022-11-26 14:01:26 +01:00
Ben Kimock
8961e13802 Use None when the stack is empty 2022-11-25 13:13:11 -05:00
Nilstrieb
2c456b5123
Test a small cargo-miri smoke test even in run_tests_minimal
This makes sure that cargo-miri works on all targets.
2022-11-25 18:28:35 +01:00
bors
fe815229c3 Auto merge of #2691 - RalfJung:get_mut, r=RalfJung
replace a borrow_mut by get_mut
2022-11-25 07:58:00 +00:00
Ralf Jung
448f044407 replace a borrow_mut by get_mut 2022-11-25 08:57:16 +01:00
Ben Kimock
a312329b0a
Update src/machine.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-11-22 22:22:47 -05:00
Ben Kimock
1ca3c293b2
Document is_user_relevant
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-11-22 10:19:29 -05:00
bors
8b0b2d136e Auto merge of #2687 - RalfJung:getrandom, r=RalfJung
ensure current getrandom works with strict provenance
2022-11-22 11:16:51 +00:00
Ralf Jung
8061e2fd53 update test_dependencies 2022-11-22 12:16:27 +01:00
Ralf Jung
859310a370 ensure current getrandom works with strict provenance 2022-11-22 11:52:35 +01:00
Ben Kimock
23270ae8d3 Incrementally track which frame to use for diagnostics 2022-11-21 18:38:10 -05:00
bors
105dba7968 Auto merge of #2684 - RalfJung:stack-borrows-weak-protectors, r=saethlin
Stack borrows: weak protectors

This addresses the issue described in https://github.com/rust-lang/unsafe-code-guidelines/issues/376.
2022-11-21 07:57:33 +00:00
Ralf Jung
32e9d00585 tweaks 2022-11-20 22:22:38 +01:00
Ralf Jung
bf9e73f6d4 some things don't need to be mutable 2022-11-20 18:15:24 +01:00
Ralf Jung
7225524744 add a weak form of protection that justifies Box noalias 2022-11-20 18:15:24 +01:00
Ralf Jung
c043a0e7d6 cfg(miri) no longer needed in sys/unix/time.rs 2022-11-20 12:13:48 +01:00
Ralf Jung
a689eb0ded update lockfile 2022-11-20 12:13:48 +01:00
bors
8459a16869 Auto merge of #2683 - RalfJung:align_offset, r=RalfJung
make align_offset always work on no-provenance pointers

Fixes https://github.com/rust-lang/miri/issues/2682
2022-11-20 10:16:02 +00:00
Ralf Jung
c8c82a0bca make align_offset always work on no-provenance pointers 2022-11-20 11:01:00 +01:00
bors
c26b510dbc Auto merge of #2681 - RalfJung:seed, r=oli-obk
make miri-seed a regular integer, and also set layout-seed in many-seeds

This makes the seed format consistent between `-Zlayout-seed` and `-Zmiri-seed`.
2022-11-20 09:49:34 +00:00
Ralf Jung
772d521616 make miri-seed a regular integer, and also set layout-seed in many-seeds 2022-11-20 10:49:13 +01:00
bors
0a9e5e8e81 Auto merge of #2680 - RalfJung:rustup, r=RalfJung
Rustup
2022-11-20 07:06:11 +00:00
Ralf Jung
4da7d4b168 fix unused warning in a test 2022-11-20 08:04:36 +01:00
Ralf Jung
3865e654f0 Merge from rustc 2022-11-20 07:48:27 +01:00
Ralf Jung
aada2d1689 Preparing for merge from rustc 2022-11-20 07:48:21 +01:00
bors
7477c1f4f7 Auto merge of #104522 - RalfJung:try_normalize_after_erasing_regions, r=oli-obk
try_normalize_after_erasing_regions: promote an assertion to always run

In https://github.com/rust-lang/miri/issues/2433 this assertion has been seen to trigger, so it might be worth actually checking this? Regressing debug assertions are very easy to miss until much later, and then they become quite hard to debug.
2022-11-20 01:16:52 +00:00
bors
fc105ef61f Auto merge of #2679 - RalfJung:clock_gettime, r=RalfJung
implement clock_gettime on macos

and pull in rustc changes so we can test this against https://github.com/rust-lang/rust/pull/103594.

Fixes https://github.com/rust-lang/miri/issues/2664
2022-11-19 22:48:10 +00:00
Ralf Jung
21321f57c2 implement clock_gettime on macos 2022-11-19 23:47:41 +01:00
bors
cd1f782b74 Auto merge of #104470 - ehuss:cdb-dupe-last-command, r=jyn514
Don't duplicate last cdb debuginfo test command

cdb scripts interpret a blank line to mean "repeat the last command", similar to what happens when running the debugger from a console. The code for compiletest that constructs the debugger script was inserting a blank line between the last command and the "quit" command. This caused the last command to be executed twice. This can cause some confusion since the `-check` lines are expecting the output in a certain order. But printing the last command twice causes that order-assumption to fail, and that can cause confusion.

This fixes it by removing the blank line.

AFAICT, gdb and lldb scripts don't have the same behavior with blank lines (and the gdb code doesn't add any blank lines anyways).
2022-11-19 22:25:18 +00:00
bors
c5d82ed7a4 Auto merge of #102795 - lukas-code:constify-is-aligned-via-align-offset, r=oli-obk
Constify `is_aligned` via `align_offset`

Alternative to https://github.com/rust-lang/rust/pull/102753

Make `align_offset` work in const eval (and not always return `usize::MAX`) and then use that to constify `is_aligned{_to}`.

Tracking Issue: https://github.com/rust-lang/rust/issues/104203
2022-11-19 18:57:39 +00:00
Lukas Markeffsky
c9c017dfb5 update provenance test
* fix allocation alignment for 16bit platforms
* add edge case where `stride % align != 0` on pointers with provenance
2022-11-19 16:58:02 +01:00
Lukas Markeffsky
53c2ee8e9b fix assembly test on apple 2022-11-19 16:58:02 +01:00
Lukas
e90d15b247 Update comment on pointer-to-usize transmute
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-11-19 16:58:02 +01:00
Lukas Markeffsky
3d7e9c4b7f Revert "don't call align_offset during const eval, ever"
This reverts commit f3a577bfae376c0222e934911865ed14cddd1539.
2022-11-19 16:58:02 +01:00
Lukas Markeffsky
9e5d497b67 fix const align_offset implementation 2022-11-19 16:57:58 +01:00
Lukas Markeffsky
8717455b9d fix assembly test on windows 2022-11-19 16:47:42 +01:00
Lukas Markeffsky
60f352fd7d replace potential ICE with graceful error (no_core only) 2022-11-19 16:47:42 +01:00
Lukas Markeffsky
8a6053618f docs cleanup
* Fix doc examples for Platforms with underaligned integer primitives.
* Mutable pointer doc examples use mutable pointers.
* Fill out tracking issue.
* Minor formatting changes.
2022-11-19 16:47:42 +01:00
Lukas Markeffsky
daccb8c11a always use align_offset in is_aligned_to + add assembly test 2022-11-19 16:47:42 +01:00
Lukas Markeffsky
4696e8906d Schrödinger's pointer
It's aligned *and* not aligned!
2022-11-19 16:47:42 +01:00
Lukas Markeffsky
df0bcfe644 address more review comments
* `cfg` only the body of `align_offset`
* put explicit panics back
* explain why `ptr.align_offset(align) == 0` is slow
2022-11-19 16:47:42 +01:00
Lukas Markeffsky
093c02ed46 document is_aligned{,_to} 2022-11-19 16:47:42 +01:00
Lukas Markeffsky
a906f6cb69 don't call align_offset during const eval, ever 2022-11-19 16:47:42 +01:00
Lukas Markeffsky
24e88066dc mark align_offset as #[must_use] 2022-11-19 16:47:42 +01:00
Lukas Markeffsky
2ef9a8ae0f add coretests for is_aligned 2022-11-19 16:47:42 +01:00
Lukas Markeffsky
6f6320a0a9 constify pointer::is_aligned{,_to} 2022-11-19 16:47:42 +01:00