Skip to content

Commit 2be0db4

Browse files
committed
Auto merge of #917 - RalfJung:isolation, r=oli-obk
change flag name: enable-communication -> disable-isolation r? @oli-obk -- I think this is a better name for the flag but it is still somewhat clumsy. Suggestions?
2 parents cae0a5e + 55efee9 commit 2be0db4

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ Several `-Z` flags are relevant for Miri:
157157
is enforced by default. This is mostly useful for debugging; it means Miri
158158
will miss bugs in your program. However, this can also help to make Miri run
159159
faster.
160-
* `-Zmiri-enable-communication` enables communication between the host
161-
environment and Miri, i.e., Miri uses the host's random number generator and
162-
all the host environment variables are available during runtime.
160+
* `-Zmiri-disable-isolation` disables host host isolation. As a consequence,
161+
the program has access to host resources such as environment variables and
162+
randomness (and, eventually, file systems and more).
163163
* `-Zmir-opt-level` controls how many MIR optimizations are performed. Miri
164164
overrides the default to be `0`; be advised that using any higher level can
165165
make Miri miss bugs in your program because they got optimized away.

src/bin/miri.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn main() {
148148
"-Zmiri-disable-validation" => {
149149
validate = false;
150150
},
151-
"-Zmiri-enable-communication" => {
151+
"-Zmiri-disable-isolation" => {
152152
communicate = true;
153153
},
154154
"--" => {

tests/run-pass/communication.rs renamed to tests/run-pass/env-without-isolation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ignore-windows: TODO env var emulation stubbed out on Windows
2-
// compile-flags: -Zmiri-enable-communication
2+
// compile-flags: -Zmiri-disable-isolation
33

44
fn main() {
55
assert_eq!(std::env::var("MIRI_ENV_VAR_TEST"), Ok("0".to_owned()));
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Unfortunately, compiletest_rs does not support 'only-linux',
2+
// so we need to ignore Windows and macOS instead.
3+
// ignore-macos: Uses Linux-only APIs
4+
// ignore-windows: Uses Linux-only APIs
5+
// compile-flags: -Zmiri-disable-isolation
6+
#![feature(rustc_private)]
7+
extern crate libc;
8+
9+
fn main() {
10+
let mut buf = [0u8; 5];
11+
unsafe {
12+
assert_eq!(libc::syscall(libc::SYS_getrandom, 0 as *mut libc::c_void, 0 as libc::size_t, 0 as libc::c_uint), 0);
13+
assert_eq!(libc::syscall(libc::SYS_getrandom, buf.as_mut_ptr() as *mut libc::c_void, 5 as libc::size_t, 0 as libc::c_uint), 5);
14+
15+
assert_eq!(libc::getrandom(0 as *mut libc::c_void, 0 as libc::size_t, 0 as libc::c_uint), 0);
16+
assert_eq!(libc::getrandom(buf.as_mut_ptr() as *mut libc::c_void, 5 as libc::size_t, 0 as libc::c_uint), 5);
17+
}
18+
}

0 commit comments

Comments
 (0)