You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of rust-lang#3701 - RalfJung:extern-type-reborrow, r=saethlin
show warning when Stacked Borrows skips a reborrow due to 'extern type'
When this happens, we can't actually be sure to catch all bugs -- LLVM will still get a `noalias` but Miri can't do reborrowing. That's not good.
"This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program."
655
+
"this program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program"
651
656
),
652
657
),
653
658
(
654
659
None,
655
660
format!(
656
-
"See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation."
661
+
"see https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation"
657
662
),
658
663
),
659
664
(
660
665
None,
661
666
format!(
662
-
"To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead."
667
+
"to ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead"
663
668
),
664
669
),
665
670
(
666
671
None,
667
672
format!(
668
-
"You can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics."
673
+
"you can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics"
669
674
),
670
675
),
671
676
(
672
677
None,
673
678
format!(
674
-
"Alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning."
679
+
"alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning"
675
680
),
676
681
),
677
682
],
683
+
ExternTypeReborrow => {
684
+
vec![
685
+
(
686
+
None,
687
+
format!(
688
+
"`extern type` are not compatible with the Stacked Borrows aliasing model implemented by Miri; Miri may miss bugs in this code"
689
+
),
690
+
),
691
+
(
692
+
None,
693
+
format!(
694
+
"try running with `MIRIFLAGS=-Zmiri-tree-borrows` to use the more permissive but also even more experimental Tree Borrows aliasing checks instead"
Copy file name to clipboardExpand all lines: src/tools/miri/tests/fail/extern-type-field-offset.stderr
+12-1
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,14 @@
1
+
warning: reborrow of reference to `extern type`
2
+
--> $DIR/extern-type-field-offset.rs:LL:CC
3
+
|
4
+
LL | let x: &Newtype = unsafe { &*(&buf as *const _ as *const Newtype) };
5
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reborrow of a reference to `extern type` is not properly supported
6
+
|
7
+
= help: `extern type` are not compatible with the Stacked Borrows aliasing model implemented by Miri; Miri may miss bugs in this code
8
+
= help: try running with `MIRIFLAGS=-Zmiri-tree-borrows` to use the more permissive but also even more experimental Tree Borrows aliasing checks instead
9
+
= note: BACKTRACE:
10
+
= note: inside `main` at $DIR/extern-type-field-offset.rs:LL:CC
11
+
1
12
error: unsupported operation: `extern type` field does not have a known offset
2
13
--> $DIR/extern-type-field-offset.rs:LL:CC
3
14
|
@@ -10,5 +21,5 @@ LL | let _field = &x.a;
10
21
11
22
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
12
23
13
-
error: aborting due to 1 previous error
24
+
error: aborting due to 1 previous error; 1 warning emitted
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program.
8
-
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation.
9
-
= help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.
10
-
= help: You can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics.
11
-
= help: Alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning.
7
+
= help: this program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program
8
+
= help: see https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation
9
+
= help: to ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead
10
+
= help: you can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics
11
+
= help: alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning
12
12
= note: BACKTRACE:
13
13
= note: inside `main` at $DIR/ptr_metadata_uninit_slice_len.rs:LL:CC
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program.
8
-
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation.
9
-
= help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.
10
-
= help: You can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics.
11
-
= help: Alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning.
7
+
= help: this program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program
8
+
= help: see https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation
9
+
= help: to ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead
10
+
= help: you can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics
11
+
= help: alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning
LL | let x: &Foo = unsafe { &*(16 as *const Foo) };
5
5
| ^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
6
6
|
7
-
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program.
8
-
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation.
9
-
= help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.
10
-
= help: You can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics.
11
-
= help: Alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning.
7
+
= help: this program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program
8
+
= help: see https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation
9
+
= help: to ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead
10
+
= help: you can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics
11
+
= help: alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning
12
+
= note: BACKTRACE:
13
+
= note: inside `main` at $DIR/extern_types.rs:LL:CC
14
+
15
+
warning: reborrow of reference to `extern type`
16
+
--> $DIR/extern_types.rs:LL:CC
17
+
|
18
+
LL | let x: &Foo = unsafe { &*(16 as *const Foo) };
19
+
| ^^^^^^^^^^^^^^^^^^^^ reborrow of a reference to `extern type` is not properly supported
20
+
|
21
+
= help: `extern type` are not compatible with the Stacked Borrows aliasing model implemented by Miri; Miri may miss bugs in this code
22
+
= help: try running with `MIRIFLAGS=-Zmiri-tree-borrows` to use the more permissive but also even more experimental Tree Borrows aliasing checks instead
12
23
= note: BACKTRACE:
13
24
= note: inside `main` at $DIR/extern_types.rs:LL:CC
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program.
8
-
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation.
9
-
= help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.
10
-
= help: You can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics.
11
-
= help: Alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning.
7
+
= help: this program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program
8
+
= help: see https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation
9
+
= help: to ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead
10
+
= help: you can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics
11
+
= help: alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning
12
12
= note: BACKTRACE:
13
13
= note: inside `main` at $DIR/issue-miri-2389.rs:LL:CC
0 commit comments