]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agomake sure 2-phase borows work even with raw ptr tagging
Ralf Jung [Thu, 21 Apr 2022 14:09:35 +0000 (16:09 +0200)]
make sure 2-phase borows work even with raw ptr tagging

2 years agoAuto merge of #2078 - RalfJung:rustup, r=RalfJung
bors [Wed, 20 Apr 2022 21:46:55 +0000 (21:46 +0000)]
Auto merge of #2078 - RalfJung:rustup, r=RalfJung

rustup

https://github.com/rust-lang/rust/pull/93313 somehow made it so that this does not have to be mutable any more...

2 years agorustup
Ralf Jung [Wed, 20 Apr 2022 21:41:09 +0000 (17:41 -0400)]
rustup

2 years agoAuto merge of #2077 - RalfJung:more-test, r=RalfJung
bors [Wed, 20 Apr 2022 14:52:53 +0000 (14:52 +0000)]
Auto merge of #2077 - RalfJung:more-test, r=RalfJung

add some more tests

2 years agoadd mut_below_shr test
Ralf Jung [Wed, 20 Apr 2022 14:47:22 +0000 (10:47 -0400)]
add mut_below_shr test

2 years agoadd another test for #2068
Ralf Jung [Wed, 20 Apr 2022 14:39:17 +0000 (10:39 -0400)]
add another test for #2068

2 years agoAuto merge of #2071 - RalfJung:provenance, r=RalfJung
bors [Wed, 20 Apr 2022 12:44:39 +0000 (12:44 +0000)]
Auto merge of #2071 - RalfJung:provenance, r=RalfJung

adjust for provenance cleanup

This is the Miri side of https://github.com/rust-lang/rust/pull/96165

2 years agoadd test for https://github.com/rust-lang/miri/issues/2068
Ralf Jung [Wed, 20 Apr 2022 12:44:10 +0000 (08:44 -0400)]
add test for https://github.com/rust-lang/miri/issues/2068

2 years agorustup
Ralf Jung [Wed, 20 Apr 2022 12:44:06 +0000 (08:44 -0400)]
rustup

2 years agoavoid into_pointer_or_addr and into_parts in visit_freeze_sensitive
Ralf Jung [Mon, 18 Apr 2022 16:38:26 +0000 (12:38 -0400)]
avoid into_pointer_or_addr and into_parts in visit_freeze_sensitive

2 years agoadjust for provenance cleanup
Ralf Jung [Mon, 18 Apr 2022 14:20:11 +0000 (10:20 -0400)]
adjust for provenance cleanup

2 years agoAuto merge of #2074 - RalfJung:tls-ro, r=RalfJung
bors [Tue, 19 Apr 2022 18:56:58 +0000 (18:56 +0000)]
Auto merge of #2074 - RalfJung:tls-ro, r=RalfJung

do not consider thread-local allocations read-only

They are not in read-only memory the way regular `static`s are.

Fixes https://github.com/rust-lang/rust/issues/96191

2 years agodo not consider thread-local allocations read-only
Ralf Jung [Tue, 19 Apr 2022 18:56:07 +0000 (14:56 -0400)]
do not consider thread-local allocations read-only

2 years agoAuto merge of #2070 - RalfJung:size-assert, r=RalfJung
bors [Mon, 18 Apr 2022 01:58:52 +0000 (01:58 +0000)]
Auto merge of #2070 - RalfJung:size-assert, r=RalfJung

add size assertions for some core types

2 years agoadd size assertions for some core types
Ralf Jung [Mon, 18 Apr 2022 01:46:42 +0000 (21:46 -0400)]
add size assertions for some core types

2 years agoAuto merge of #2067 - RalfJung:strerror_r, r=RalfJung
bors [Sun, 17 Apr 2022 02:54:53 +0000 (02:54 +0000)]
Auto merge of #2067 - RalfJung:strerror_r, r=RalfJung

implement strerror_r

This isn't perfect; we end up using [this match](https://github.com/rust-lang/rust/blob/72a25d05bf1a4b155d74139ef700ff93af6d8e22/library/std/src/io/error.rs#L380) rather than the platform-specific messages, but at least we show something -- this is mostly informational anyway.

Cc https://github.com/rust-lang/miri/issues/2057

2 years agoimplement strerror_r
Ralf Jung [Sun, 17 Apr 2022 02:50:46 +0000 (22:50 -0400)]
implement strerror_r

2 years agoAuto merge of #2065 - RalfJung:readme, r=RalfJung
bors [Sat, 16 Apr 2022 13:17:56 +0000 (13:17 +0000)]
Auto merge of #2065 - RalfJung:readme, r=RalfJung

readme

We support SIMD these days. :D At least via portable-simd.

2 years agoreadme
Ralf Jung [Sat, 16 Apr 2022 13:13:40 +0000 (09:13 -0400)]
readme

2 years agoAuto merge of #2064 - RalfJung:rustup, r=RalfJung
bors [Sat, 16 Apr 2022 12:42:58 +0000 (12:42 +0000)]
Auto merge of #2064 - RalfJung:rustup, r=RalfJung

rustup

2 years agorustup
Ralf Jung [Sat, 16 Apr 2022 12:41:34 +0000 (08:41 -0400)]
rustup

2 years agoAuto merge of #2063 - RalfJung:macos-timeout, r=RalfJung
bors [Sun, 10 Apr 2022 15:24:33 +0000 (15:24 +0000)]
Auto merge of #2063 - RalfJung:macos-timeout, r=RalfJung

increase slack for timeout test

This still sometimes fails on macOS, so let's increase the slack.

2 years agoincrease slack for timeout test
Ralf Jung [Sun, 10 Apr 2022 15:23:56 +0000 (11:23 -0400)]
increase slack for timeout test

2 years agoAuto merge of #2062 - RalfJung:rustup, r=RalfJung
bors [Sun, 10 Apr 2022 13:37:33 +0000 (13:37 +0000)]
Auto merge of #2062 - RalfJung:rustup, r=RalfJung

rustup

https://github.com/rust-lang/rust/pull/95621 made channels strict provenance compliant. :)

2 years agorustup
Ralf Jung [Sun, 10 Apr 2022 13:36:30 +0000 (09:36 -0400)]
rustup

2 years agoAuto merge of #2061 - RalfJung:edition, r=RalfJung
bors [Sat, 9 Apr 2022 16:45:09 +0000 (16:45 +0000)]
Auto merge of #2061 - RalfJung:edition, r=RalfJung

port Miri to edition 2021

`cargo fix --edition` didn't change anything for either of these crates, so this looks like a very simple port. And then we can remove a bunch of annoying imports. :)

I thought this also unlocks the named format string stuff, but it seems that works on all editions except for that problem around `panic!`. Whatever. ;)

2 years agouse new format string syntax in some places
Ralf Jung [Sat, 9 Apr 2022 15:22:18 +0000 (11:22 -0400)]
use new format string syntax in some places

2 years agoremove no longer needed imports
Ralf Jung [Sat, 9 Apr 2022 15:20:32 +0000 (11:20 -0400)]
remove no longer needed imports

2 years agoport cargo-miri to edition 2021
Ralf Jung [Sat, 9 Apr 2022 15:17:16 +0000 (11:17 -0400)]
port cargo-miri to edition 2021

2 years agoport Miri to edition 2021
Ralf Jung [Sat, 9 Apr 2022 15:16:50 +0000 (11:16 -0400)]
port Miri to edition 2021

2 years agoAuto merge of #2060 - RalfJung:rustup, r=RalfJung
bors [Sat, 9 Apr 2022 13:42:12 +0000 (13:42 +0000)]
Auto merge of #2060 - RalfJung:rustup, r=RalfJung

rustup

Cc https://github.com/rust-lang/rust/issues/95844

2 years agorustup
Ralf Jung [Sat, 9 Apr 2022 13:41:29 +0000 (09:41 -0400)]
rustup

2 years agoAuto merge of #2055 - RalfJung:rustup, r=RalfJung
bors [Fri, 8 Apr 2022 13:57:45 +0000 (13:57 +0000)]
Auto merge of #2055 - RalfJung:rustup, r=RalfJung

Rustup

Fixes https://github.com/rust-lang/miri/issues/1717

2 years agorustup
Ralf Jung [Fri, 8 Apr 2022 12:01:19 +0000 (08:01 -0400)]
rustup

2 years agothread name setting works with strict provenance now :)
Ralf Jung [Thu, 7 Apr 2022 20:39:18 +0000 (16:39 -0400)]
thread name setting works with strict provenance now :)

2 years agofix Windows stdout/stderr
Ralf Jung [Thu, 7 Apr 2022 19:03:57 +0000 (15:03 -0400)]
fix Windows stdout/stderr

2 years agoAuto merge of #2058 - RalfJung:variadic, r=RalfJung
bors [Fri, 8 Apr 2022 13:08:08 +0000 (13:08 +0000)]
Auto merge of #2058 - RalfJung:variadic, r=RalfJung

For variadic functions, accept arbitrary trailing arguments

However, make sure that if we use argument N we check the size of all arguments before that, because otherwise this might not work properly depending on how varargs are implemented. This caught bugs in our futex tests. ;)

I couldn't find a good way to systematically ensure this, so it is just something we have to be on the look for during review. (This generally applies also for fixed-arg shims: we should check the size of each parameter.)

Also treat prctl like a variadic function, Cc `@saethlin.`

2 years agotreat prctl like a variadic function
Ralf Jung [Thu, 7 Apr 2022 20:14:50 +0000 (16:14 -0400)]
treat prctl like a variadic function

2 years agofor variadic functions, accept arbitrary trailing arguments but make sure we check...
Ralf Jung [Thu, 7 Apr 2022 19:27:57 +0000 (15:27 -0400)]
for variadic functions, accept arbitrary trailing arguments but make sure we check all leading arguments

2 years agoadd machine hook tcx parameters
Ralf Jung [Wed, 6 Apr 2022 22:30:25 +0000 (18:30 -0400)]
add machine hook tcx parameters

2 years agoAuto merge of #2056 - RalfJung:rustup2, r=RalfJung
bors [Thu, 7 Apr 2022 12:59:13 +0000 (12:59 +0000)]
Auto merge of #2056 - RalfJung:rustup2, r=RalfJung

rustup

Let's go in smaller steps, this might work better than https://github.com/rust-lang/miri/pull/2055

2 years agorustup
Ralf Jung [Thu, 7 Apr 2022 12:35:29 +0000 (08:35 -0400)]
rustup

2 years agoAuto merge of #2054 - m-ou-se:futex-wait-bitset, r=RalfJung
bors [Wed, 6 Apr 2022 22:20:11 +0000 (22:20 +0000)]
Auto merge of #2054 - m-ou-se:futex-wait-bitset, r=RalfJung

Add support for FUTEX_{WAIT,WAKE}_BITSET

FUTEX_WAIT_BITSET and FUTEX_WAKE_BITSET are extensions of FUTEX_WAIT and FUTEX_WAKE that allow tagging each waiting thread with up to 32 'labels', and then only wake up threads that match certain labels. The non-bitset operations behave like their bitset was fully set (u32::MAX), meaning that they'll wait for anything, and wake up anything.

The only other difference is that FUTEX_WAIT_BITSET uses an absolute timeout instead of an relative timeout like FUTEX_WAIT.

Often, FUTEX_WAIT_BITSET is used not for its bitset functionality, but only for its absolute timeout functionality. It is then used with a bitset of u32::MAX.

~~This adds support for only that use case to Miri, as that's all `std` currently needs. Any other bitset is still unsupported.~~

Update: This adds full support for both these syscalls.

2 years agoPut 306ba8357fb36212b7d30efb9eb9e41659ac1445 in rust-version.
Mara Bos [Wed, 6 Apr 2022 22:02:20 +0000 (00:02 +0200)]
Put 306ba8357fb36212b7d30efb9eb9e41659ac1445 in rust-version.

2 years agoUse `let = if;` instead of `let; if`.
Mara Bos [Wed, 6 Apr 2022 21:55:02 +0000 (23:55 +0200)]
Use `let = if;` instead of `let; if`.

2 years agoAdd test for FUTEX_*_BITSET.
Mara Bos [Wed, 6 Apr 2022 21:48:26 +0000 (23:48 +0200)]
Add test for FUTEX_*_BITSET.

2 years agoFully support FUTEX_*_BITSET.
Mara Bos [Wed, 6 Apr 2022 21:48:14 +0000 (23:48 +0200)]
Fully support FUTEX_*_BITSET.

2 years agoFormatting.
Mara Bos [Wed, 6 Apr 2022 21:13:47 +0000 (23:13 +0200)]
Formatting.

2 years agoAdd test for FUTEX_WAIT_BITSET.
Mara Bos [Wed, 6 Apr 2022 21:04:15 +0000 (23:04 +0200)]
Add test for FUTEX_WAIT_BITSET.

2 years agoAdd support for FUTEX_WAIT_BITSET(bitset=MAX).
Mara Bos [Wed, 6 Apr 2022 21:03:52 +0000 (23:03 +0200)]
Add support for FUTEX_WAIT_BITSET(bitset=MAX).

2 years agoAuto merge of #2050 - RalfJung:partially-uninit, r=RalfJung
bors [Tue, 5 Apr 2022 22:31:24 +0000 (22:31 +0000)]
Auto merge of #2050 - RalfJung:partially-uninit, r=RalfJung

test that partially uninit MaybeUninit works correctly

This got finally fixed by https://github.com/rust-lang/rust/pull/94527 :)

2 years agotest that partially uninit MaybeUninit works correctly
Ralf Jung [Tue, 5 Apr 2022 22:29:17 +0000 (18:29 -0400)]
test that partially uninit MaybeUninit works correctly

2 years agoAuto merge of #2047 - RalfJung:no-extras, r=RalfJung
bors [Tue, 5 Apr 2022 15:14:12 +0000 (15:14 +0000)]
Auto merge of #2047 - RalfJung:no-extras, r=RalfJung

adjust for MemoryExtra being merged into Machine

The Miri side of https://github.com/rust-lang/rust/pull/95620

2 years agorustup
Ralf Jung [Tue, 5 Apr 2022 15:10:21 +0000 (11:10 -0400)]
rustup

2 years agoadjust for MemoryExtra being merged into Machine
Ralf Jung [Sun, 3 Apr 2022 20:12:52 +0000 (16:12 -0400)]
adjust for MemoryExtra being merged into Machine

2 years agoAuto merge of #2049 - atouchet:lic, r=RalfJung
bors [Tue, 5 Apr 2022 02:29:21 +0000 (02:29 +0000)]
Auto merge of #2049 - atouchet:lic, r=RalfJung

Use SPDX license format

2 years agoUse SPDX license format
Alex Touchet [Mon, 4 Apr 2022 22:52:09 +0000 (15:52 -0700)]
Use SPDX license format

2 years agoAuto merge of #2046 - RalfJung:very-strict, r=RalfJung
bors [Mon, 4 Apr 2022 19:54:01 +0000 (19:54 +0000)]
Auto merge of #2046 - RalfJung:very-strict, r=RalfJung

make strict-provenance imply check-number-validity

I feel like Miri not catching [this example](https://github.com/rust-lang/unsafe-code-guidelines/issues/286#issuecomment-1085144431) with strict provenance checking enabled is surprising.

OTOH, Miri suddenly complaining about uninit data in integers with `-Zmiri-strict-provenance` also might be surprising. Which one is more surprising? I don't know. We *could* go out of our way and have a mode where uninit integers are okay but provenance is not, but I am not sure if that is truly worth it. It'd be quite annoying to implement.

2 years agoAuto merge of #2048 - RalfJung:rustup, r=RalfJung
bors [Mon, 4 Apr 2022 00:01:53 +0000 (00:01 +0000)]
Auto merge of #2048 - RalfJung:rustup, r=RalfJung

rustup

2 years agorustup
Ralf Jung [Mon, 4 Apr 2022 00:00:03 +0000 (20:00 -0400)]
rustup

2 years agoadd test for nasty example
Ralf Jung [Sat, 2 Apr 2022 04:05:27 +0000 (00:05 -0400)]
add test for nasty example

2 years agomake strict-provenance imply check-number-validity
Ralf Jung [Sat, 2 Apr 2022 03:59:16 +0000 (23:59 -0400)]
make strict-provenance imply check-number-validity

2 years agoAuto merge of #2045 - RalfJung:strict-provenance, r=RalfJung
bors [Fri, 1 Apr 2022 22:40:26 +0000 (22:40 +0000)]
Auto merge of #2045 - RalfJung:strict-provenance, r=RalfJung

add -Zmiri-strict-provenance

This implements [strict provenance](https://github.com/rust-lang/rust/issues/95228) in Miri. The only change is that casting an integer to a pointer does not even attempt to produce a good provenance for the given address; instead, it always uses the invalid provenance. This stricter than even `-Zmiri-tag-raw-pointers` in that it also rejects the following example (which does not even involve Stacked Borrows):
```rust
fn main() {
    let x = 22;
    let ptr = &x as *const _ as *const u8;
    let roundtrip = ptr as usize as *const u8;
    let _ = unsafe { roundtrip.offset(1) };
}
```
The new flag also implies `-Zmiri-tag-raw-pointers` since the only reason one would *not* want to tag raw pointers is to support ptr-int-ptr roundtrips.

Note that the flag does *not* check against ptr-to-int *transmutes*; that still requires `-Zmiri-check-number-validity`. You can also check for strict provenance *without* Stacked Borrows by adding `-Zmiri-disable-stacked-borrows`.

The new "Miri hard mode" flags for maximal checking are `-Zmiri-strict-provenance -Zmiri-check-number-validity`. (Add `-Zmiri-symbolic-alignment-check` if you feel extra spicy today.)

2 years agoAuto merge of #2043 - RalfJung:max-size, r=RalfJung
bors [Fri, 1 Apr 2022 21:22:59 +0000 (21:22 +0000)]
Auto merge of #2043 - RalfJung:max-size, r=RalfJung

Rust values can be up to isize::MAX in size

Needs https://github.com/rust-lang/rust/pull/95388

2 years agorustup
Ralf Jung [Fri, 1 Apr 2022 21:22:11 +0000 (17:22 -0400)]
rustup

2 years agoRust values can be up to isize::MAX in size
Ralf Jung [Mon, 28 Mar 2022 00:01:04 +0000 (20:01 -0400)]
Rust values can be up to isize::MAX in size

2 years agoadd -Zmiri-strict-provenance
Ralf Jung [Fri, 1 Apr 2022 18:10:24 +0000 (14:10 -0400)]
add -Zmiri-strict-provenance

2 years agoAuto merge of #2044 - RalfJung:int_log, r=RalfJung
bors [Thu, 31 Mar 2022 15:22:18 +0000 (15:22 +0000)]
Auto merge of #2044 - RalfJung:int_log, r=RalfJung

test int_log functions

I'll have to disable many of their tests in libcore since they take too long, so let's add some of them back on our side here.

2 years agotest int_log functions
Ralf Jung [Thu, 31 Mar 2022 15:18:56 +0000 (11:18 -0400)]
test int_log functions

2 years agoAuto merge of #2040 - RalfJung:pnvi, r=RalfJung
bors [Sun, 27 Mar 2022 14:02:02 +0000 (14:02 +0000)]
Auto merge of #2040 - RalfJung:pnvi, r=RalfJung

ensure that -Zmiri-check-number-validity detects integers with provenance

This actually currently *fails* for the non-array case; I will have to fix this on the rustc side.

2 years agoAuto merge of #2042 - TaKO8Ki:add-vscode-dir-to-gitignore, r=RalfJung
bors [Sun, 27 Mar 2022 13:41:38 +0000 (13:41 +0000)]
Auto merge of #2042 - TaKO8Ki:add-vscode-dir-to-gitignore, r=RalfJung

Add `.vscode` directory to `.gitignore`

Add `.vscode` directory to `.gitignore` for configuring `rust-analyzer`

2 years agorustup
Ralf Jung [Sun, 27 Mar 2022 13:40:46 +0000 (09:40 -0400)]
rustup

2 years agoadd .vscode to .gitignore
Takayuki Maeda [Sun, 27 Mar 2022 09:41:40 +0000 (18:41 +0900)]
add .vscode to .gitignore

2 years agochannels do ptr-int transmutes so move them to non-check-number-validity test
Ralf Jung [Sat, 26 Mar 2022 18:33:17 +0000 (14:33 -0400)]
channels do ptr-int transmutes so move them to non-check-number-validity test

2 years agofix types in env shim to avoid ptr-int transmutes
Ralf Jung [Sat, 26 Mar 2022 18:29:58 +0000 (14:29 -0400)]
fix types in env shim to avoid ptr-int transmutes

2 years agoensure that -Zmiri-check-number-validity detects integers with provenance
Ralf Jung [Sat, 26 Mar 2022 17:10:20 +0000 (13:10 -0400)]
ensure that -Zmiri-check-number-validity detects integers with provenance

2 years agoAuto merge of #2039 - RalfJung:too-big, r=RalfJung
bors [Sat, 26 Mar 2022 15:08:43 +0000 (15:08 +0000)]
Auto merge of #2039 - RalfJung:too-big, r=RalfJung

another test for too big type

The existing test covers "slice is bigger than largest supported object" but we had no test covering "total size is bigger than largest supported object", which happens when the unsized tail itself is okay in terms of size, but together with the sized prefix it becomes too big.

Cc https://github.com/rust-lang/rust/issues/95334

2 years agoanother test for too big type
Ralf Jung [Sat, 26 Mar 2022 14:44:30 +0000 (10:44 -0400)]
another test for too big type

2 years agoAuto merge of #2036 - RalfJung:vec, r=RalfJung
bors [Thu, 24 Mar 2022 14:33:02 +0000 (14:33 +0000)]
Auto merge of #2036 - RalfJung:vec, r=RalfJung

regression test for reverse() unsoundness

Cc https://github.com/rust-lang/rust/pull/90821

2 years agoAuto merge of #2038 - RalfJung:rustup, r=RalfJung
bors [Thu, 24 Mar 2022 14:07:06 +0000 (14:07 +0000)]
Auto merge of #2038 - RalfJung:rustup, r=RalfJung

rustup

2 years agorustup
Ralf Jung [Thu, 24 Mar 2022 14:06:33 +0000 (10:06 -0400)]
rustup

2 years agoregression test for reverse() unsoundness
Ralf Jung [Tue, 22 Mar 2022 18:28:36 +0000 (14:28 -0400)]
regression test for reverse() unsoundness

2 years agovec test: check number validity
Ralf Jung [Tue, 22 Mar 2022 18:26:40 +0000 (14:26 -0400)]
vec test: check number validity

2 years agoAuto merge of #2033 - RalfJung:arbitrary-self-dyn, r=RalfJung
bors [Sun, 20 Mar 2022 18:04:55 +0000 (18:04 +0000)]
Auto merge of #2033 - RalfJung:arbitrary-self-dyn, r=RalfJung

test arbitrary-self dyn receivers

Requires https://github.com/rust-lang/rust/pull/95071

2 years agorustup
Ralf Jung [Sun, 20 Mar 2022 18:04:05 +0000 (14:04 -0400)]
rustup

2 years agotest arbitrary-self dyn receivers
Ralf Jung [Fri, 18 Mar 2022 12:50:49 +0000 (08:50 -0400)]
test arbitrary-self dyn receivers

2 years agoAuto merge of #2022 - RalfJung:remove_dir_all, r=RalfJung
bors [Sun, 20 Mar 2022 14:38:27 +0000 (14:38 +0000)]
Auto merge of #2022 - RalfJung:remove_dir_all, r=RalfJung

test remove_dir_all

Blocked on https://github.com/rust-lang/rust/pull/94749

Cc https://github.com/rust-lang/miri/issues/1966

2 years agorustup
Ralf Jung [Sun, 20 Mar 2022 14:36:44 +0000 (10:36 -0400)]
rustup

2 years agotest remove_dir_all
Ralf Jung [Sat, 12 Mar 2022 18:37:46 +0000 (13:37 -0500)]
test remove_dir_all

2 years agoAuto merge of #1975 - DrMeepster:backtrace_fix, r=RalfJung
bors [Sun, 20 Mar 2022 02:37:09 +0000 (02:37 +0000)]
Auto merge of #1975 - DrMeepster:backtrace_fix, r=RalfJung

Make backtraces work with #[global_allocator]

Currently, backtraces break when the global allocator is overridden because the allocator will attempt to deallocate memory allocated directly by Miri.

~~This PR fixes that by using a new memory kind and providing a function to deallocate it. We can't call the custom allocator to allocate because it's not possible to call a function in the middle of a shim.~~

This PR fixes that by adding a new version of the backtrace API accessible by setting `flags` to 1. Existing code still functions.

backtrace-rs PR: rust-lang/backtrace-rs#462

Fixes https://github.com/rust-lang/miri/issues/1996

2 years agoadd new version of backtrace api using flags=1
DrMeepster [Fri, 25 Feb 2022 06:11:20 +0000 (22:11 -0800)]
add new version of backtrace api using flags=1

2 years agoAuto merge of #2024 - saethlin:better-local-check, r=RalfJung
bors [Fri, 18 Mar 2022 20:38:37 +0000 (20:38 +0000)]
Auto merge of #2024 - saethlin:better-local-check, r=RalfJung

Consider the cargo workspace when checking if a frame is local

`DefId::is_local` returns a result which is technically correct, but doesn't match the user's intuition when running integration tests or doctests. This incorporates the workspace crates mentioned in `cargo metadata` into the check for whether a frame is local to match user intuition.

For example, here is the backtrace you get from `MIRIFLAGS=-Zmiri-tag-raw-pointers cargo miri test` in `bytes` 1.1.0:
```
   --> /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/slice/raw.rs:131:14
    |
131 |     unsafe { &mut *ptr::slice_from_raw_parts_mut(data, len) }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to reborrow for Unique at alloc67158, but parent tag <untagged> does not have an appropriate item in the borrow stack
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information

    = note: inside `std::slice::from_raw_parts_mut::<u8>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/slice/raw.rs:131:14
    = note: inside `bytes::bytes::rebuild_boxed_slice` at /tmp/bytes-1.1.0/src/bytes.rs:938:19
    = note: inside closure at /tmp/bytes-1.1.0/src/bytes.rs:904:18
    = note: inside `<std::sync::atomic::AtomicPtr<()> as bytes::loom::sync::atomic::AtomicMut<()>>::with_mut::<[closure@bytes::bytes::promotable_even_drop::{closure#0}], ()>` at /tmp/bytes-1.1.0/src/loom.rs:17:17
    = note: inside `bytes::bytes::promotable_even_drop` at /tmp/bytes-1.1.0/src/bytes.rs:895:5
    = note: inside `<bytes::Bytes as std::ops::Drop>::drop` at /tmp/bytes-1.1.0/src/bytes.rs:515:18
    = note: inside `std::ptr::drop_in_place::<bytes::Bytes> - shim(Some(bytes::Bytes))` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:188:1
note: inside `copy_to_bytes_less` at tests/test_buf.rs:112:1
   --> tests/test_buf.rs:112:1
    |
112 | }
    | ^
note: inside closure at tests/test_buf.rs:106:1
   --> tests/test_buf.rs:106:1
    |
105 |   #[test]
    |   ------- in this procedural macro expansion
106 | / fn copy_to_bytes_less() {
107 | |     let mut buf = &b"hello world"[..];
108 | |
109 | |     let bytes = buf.copy_to_bytes(5);
110 | |     assert_eq!(bytes, &b"hello"[..]);
111 | |     assert_eq!(buf, &b" world"[..])
112 | | }
    | |_^
    = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
```
We get these because the integration tests are occurring in a crate called `test`, not the actual `bytes` crate. With this PR, we get this:
```
    = note: inside `std::slice::from_raw_parts_mut::<u8>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/slice/raw.rs:131:14
note: inside `bytes::bytes::rebuild_boxed_slice` at /tmp/bytes-1.1.0/src/bytes.rs:938:19
   --> /tmp/bytes-1.1.0/src/bytes.rs:938:19
    |
938 |     Box::from_raw(slice::from_raw_parts_mut(buf, cap))
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure at /tmp/bytes-1.1.0/src/bytes.rs:904:18
   --> /tmp/bytes-1.1.0/src/bytes.rs:904:18
    |
904 |             drop(rebuild_boxed_slice(buf, ptr, len));
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `<std::sync::atomic::AtomicPtr<()> as bytes::loom::sync::atomic::AtomicMut<()>>::with_mut::<[closure@bytes::bytes::promotable_even_drop::{closure#0}], ()>` at /tmp/bytes-1.1.0/src/loom.rs:17:17
   --> /tmp/bytes-1.1.0/src/loom.rs:17:17
    |
17  |                 f(self.get_mut())
    |                 ^^^^^^^^^^^^^^^^^
note: inside `bytes::bytes::promotable_even_drop` at /tmp/bytes-1.1.0/src/bytes.rs:895:5
   --> /tmp/bytes-1.1.0/src/bytes.rs:895:5
    |
895 | /     data.with_mut(|shared| {
896 | |         let shared = *shared;
897 | |         let kind = shared as usize & KIND_MASK;
898 | |
...   |
905 | |         }
906 | |     });
    | |______^
note: inside `<bytes::Bytes as std::ops::Drop>::drop` at /tmp/bytes-1.1.0/src/bytes.rs:515:18
   --> /tmp/bytes-1.1.0/src/bytes.rs:515:18
    |
515 |         unsafe { (self.vtable.drop)(&mut self.data, self.ptr, self.len) }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: inside `std::ptr::drop_in_place::<bytes::Bytes> - shim(Some(bytes::Bytes))` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:188:1
note: inside `copy_to_bytes_less` at tests/test_buf.rs:112:1
   --> tests/test_buf.rs:112:1
    |
112 | }
    | ^
note: inside closure at tests/test_buf.rs:106:1
   --> tests/test_buf.rs:106:1
    |
105 |   #[test]
    |   ------- in this procedural macro expansion
106 | / fn copy_to_bytes_less() {
107 | |     let mut buf = &b"hello world"[..];
108 | |
109 | |     let bytes = buf.copy_to_bytes(5);
110 | |     assert_eq!(bytes, &b"hello"[..]);
111 | |     assert_eq!(buf, &b" world"[..])
112 | | }
    | |_^
    = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
```

Note that this kind of inflation is rather rare to see. Most backtraces change not at all or only a tiny bit.

I originally implemented this to support another improvement to Miri diagnostics, but I think this is hairy enough to deserve its own PR, if somewhat poorly-motivated.

2 years agoConsider the cargo workspace when checking if a frame is local
Ben Kimock [Sat, 12 Mar 2022 22:23:22 +0000 (17:23 -0500)]
Consider the cargo workspace when checking if a frame is local

2 years agoAuto merge of #2029 - RalfJung:simd-bitmask, r=RalfJung
bors [Thu, 17 Mar 2022 17:18:01 +0000 (17:18 +0000)]
Auto merge of #2029 - RalfJung:simd-bitmask, r=RalfJung

implement simd bitmask intrinsics

Cc https://github.com/rust-lang/miri/issues/1912

2 years agofix simd_bitmask shorter than a byte on big-endian
Ralf Jung [Thu, 17 Mar 2022 17:14:16 +0000 (13:14 -0400)]
fix simd_bitmask shorter than a byte on big-endian

2 years agodetect when unused bits of a SIMD bitmask are non-0
Ralf Jung [Thu, 17 Mar 2022 00:52:01 +0000 (20:52 -0400)]
detect when unused bits of a SIMD bitmask are non-0

2 years agoimplement simd bitmask intrinsics
Ralf Jung [Thu, 17 Mar 2022 00:33:54 +0000 (20:33 -0400)]
implement simd bitmask intrinsics

2 years agoAuto merge of #1971 - saethlin:sb-details, r=RalfJung
bors [Thu, 17 Mar 2022 13:26:29 +0000 (13:26 +0000)]
Auto merge of #1971 - saethlin:sb-details, r=RalfJung

Add a lot more information to SB fatal errors

In fatal errors, this clarifies the difference between a tag not being present in the borrow stack at all, and the tag being present but granting SRO. It also introduces a little notation for memory ranges so we can mention to the user that the span may point to code that operates on multiple memory locations, but we are reporting an error at a particular offset.

This also gets rid of the unqualified phrase "the borrow stack" in errors, and clarifies that it is the borrow stack _for some location_.

The crate `pdqselect` v0.1.1:
Before:
```
2103 |     unsafe { copy_nonoverlapping(src, dst, count) }
     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item granting read access to tag <2357> at alloc1029 found in borrow stack.
```
After:
```
2103 |     unsafe { copy_nonoverlapping(src, dst, count) }
     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |              |
     |              attempting a read access using <2357> at alloc1029[0x0], but that tag does not exist in the borrow stack for this location
     |              this error occurs as part of an access at alloc1029[0x0..0x4]
```

And the crate `half` v1.8.2
Before:
```
131 |     unsafe { &mut *ptr::slice_from_raw_parts_mut(data, len) }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to reborrow for Unique at alloc1051, but parent tag <2091> does not have an appropriate item in the borrow stack
```
After:
```
131 |     unsafe { &mut *ptr::slice_from_raw_parts_mut(data, len) }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |              |
    |              trying to reborrow <2091> for Unique permission at alloc1051[0x0], but that tag only grants SharedReadOnly permission for this location
    |              this error occurs as part of a reborrow at alloc1051[0x0..0x6]
```

2 years agoAuto merge of #2031 - RalfJung:simd, r=RalfJung
bors [Thu, 17 Mar 2022 02:15:16 +0000 (02:15 +0000)]
Auto merge of #2031 - RalfJung:simd, r=RalfJung

implement SIMD sqrt and fma

Cc https://github.com/rust-lang/miri/issues/1912

2 years agoimplement SIMD sqrt and fma
Ralf Jung [Thu, 17 Mar 2022 02:12:39 +0000 (22:12 -0400)]
implement SIMD sqrt and fma