-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4098 from RalfJung/native-call-warning
add warning explaining the limitations of the native code mode
- Loading branch information
Showing
5 changed files
with
88 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
warning: sharing memory with a native function | ||
--> tests/native-lib/pass/ptr_read_access.rs:LL:CC | ||
| | ||
LL | unsafe { print_pointer(&x) }; | ||
| ^^^^^^^^^^^^^^^^^ sharing memory with a native function called via FFI | ||
| | ||
= help: when memory is shared with a native function call, Miri stops tracking initialization and provenance for that memory | ||
= help: in particular, Miri assumes that the native call initializes all memory it has access to | ||
= help: Miri also assumes that any part of this memory may be a pointer that is permitted to point to arbitrary exposed memory | ||
= help: what this means is that Miri will easily miss Undefined Behavior related to incorrect usage of this shared memory, so you should not take a clean Miri run as a signal that your FFI code is UB-free | ||
= note: BACKTRACE: | ||
= note: inside `test_access_pointer` at tests/native-lib/pass/ptr_read_access.rs:LL:CC | ||
note: inside `main` | ||
--> tests/native-lib/pass/ptr_read_access.rs:LL:CC | ||
| | ||
LL | test_access_pointer(); | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
warning: sharing memory with a native function | ||
--> tests/native-lib/pass/ptr_write_access.rs:LL:CC | ||
| | ||
LL | unsafe { increment_int(&mut x) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^ sharing memory with a native function called via FFI | ||
| | ||
= help: when memory is shared with a native function call, Miri stops tracking initialization and provenance for that memory | ||
= help: in particular, Miri assumes that the native call initializes all memory it has access to | ||
= help: Miri also assumes that any part of this memory may be a pointer that is permitted to point to arbitrary exposed memory | ||
= help: what this means is that Miri will easily miss Undefined Behavior related to incorrect usage of this shared memory, so you should not take a clean Miri run as a signal that your FFI code is UB-free | ||
= note: BACKTRACE: | ||
= note: inside `test_increment_int` at tests/native-lib/pass/ptr_write_access.rs:LL:CC | ||
note: inside `main` | ||
--> tests/native-lib/pass/ptr_write_access.rs:LL:CC | ||
| | ||
LL | test_increment_int(); | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|