Skip to content

Commit dfa6f88

Browse files
committed
Auto merge of #2552 - RalfJung:env-term, r=oli-obk
remove Windows TERM env var hack and -Zmiri-env-exclude The hack should not be needed any more since rust-lang/rust#100206. And that also mostly removes the need for `-Zmiri-env-exclude` -- if needed, users can still achieve the same by running `(unset VAR; cargo miri test)`. I am keeping `-Zmiri-env-forward` since it is still useful, e.g. to have RUST_BACKTRACE=full set in an otherwise deterministic execution. `@rust-lang/miri` any objections to removing `-Zmiri-env-exclude`?
2 parents d9ad25e + dd80b1a commit dfa6f88

File tree

6 files changed

+12
-28
lines changed

6 files changed

+12
-28
lines changed

README.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,9 @@ environment variable. We first document the most relevant and most commonly used
288288
execution with a "permission denied" error being returned to the program.
289289
`warn` prints a full backtrace when that happens; `warn-nobacktrace` is less
290290
verbose. `hide` hides the warning entirely.
291-
* `-Zmiri-env-exclude=<var>` keeps the `var` environment variable isolated from the host so that it
292-
cannot be accessed by the program. Can be used multiple times to exclude several variables. The
293-
`TERM` environment variable is excluded by default in Windows to prevent the libtest harness from
294-
accessing the file system. This has no effect unless `-Zmiri-disable-isolation` is also set.
295291
* `-Zmiri-env-forward=<var>` forwards the `var` environment variable to the interpreted program. Can
296-
be used multiple times to forward several variables. This takes precedence over
297-
`-Zmiri-env-exclude`: if a variable is both forwarded and exluced, it *will* get forwarded. This
298-
means in particular `-Zmiri-env-forward=TERM` overwrites the default exclusion of `TERM`.
292+
be used multiple times to forward several variables. Execution will still be deterministic if the
293+
value of forwarded variables stays the same. Has no effect if `-Zmiri-disable-isolation` is set.
299294
* `-Zmiri-ignore-leaks` disables the memory leak checker, and also allows some
300295
remaining threads to exist when the main thread exits.
301296
* `-Zmiri-permissive-provenance` disables the warning for integer-to-pointer casts and

src/bin/miri.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,10 @@ fn main() {
441441
"-Zmiri-seed should only contain valid hex digits [0-9a-fA-F] and must fit into a u64 (max 16 characters)"
442442
));
443443
miri_config.seed = Some(seed);
444-
} else if let Some(param) = arg.strip_prefix("-Zmiri-env-exclude=") {
445-
miri_config.excluded_env_vars.push(param.to_owned());
444+
} else if let Some(_param) = arg.strip_prefix("-Zmiri-env-exclude=") {
445+
show_error!(
446+
"`-Zmiri-env-exclude` has been removed; unset env vars before starting Miri instead"
447+
);
446448
} else if let Some(param) = arg.strip_prefix("-Zmiri-env-forward=") {
447449
miri_config.forwarded_env_vars.push(param.to_owned());
448450
} else if let Some(param) = arg.strip_prefix("-Zmiri-track-pointer-tag=") {

src/eval.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub enum BacktraceStyle {
7474
#[derive(Clone)]
7575
pub struct MiriConfig {
7676
/// The host environment snapshot to use as basis for what is provided to the interpreted program.
77-
/// (This is still subject to isolation as well as `excluded_env_vars` and `forwarded_env_vars`.)
77+
/// (This is still subject to isolation as well as `forwarded_env_vars`.)
7878
pub env: Vec<(OsString, OsString)>,
7979
/// Determine if validity checking is enabled.
8080
pub validate: bool,
@@ -88,8 +88,6 @@ pub struct MiriConfig {
8888
pub isolated_op: IsolatedOp,
8989
/// Determines if memory leaks should be ignored.
9090
pub ignore_leaks: bool,
91-
/// Environment variables that should always be isolated from the host.
92-
pub excluded_env_vars: Vec<String>,
9391
/// Environment variables that should always be forwarded from the host.
9492
pub forwarded_env_vars: Vec<String>,
9593
/// Command-line arguments passed to the interpreted program.
@@ -146,7 +144,6 @@ impl Default for MiriConfig {
146144
check_abi: true,
147145
isolated_op: IsolatedOp::Reject(RejectOpWith::Abort),
148146
ignore_leaks: false,
149-
excluded_env_vars: vec![],
150147
forwarded_env_vars: vec![],
151148
args: vec![],
152149
seed: None,

src/shims/env.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,12 @@ impl<'tcx> EnvVars<'tcx> {
4242
config: &MiriConfig,
4343
) -> InterpResult<'tcx> {
4444
let target_os = ecx.tcx.sess.target.os.as_ref();
45-
let mut excluded_env_vars = config.excluded_env_vars.clone();
46-
if target_os == "windows" {
47-
// HACK: Exclude `TERM` var to avoid terminfo trying to open the termcap file.
48-
excluded_env_vars.push("TERM".to_owned());
49-
}
5045

5146
// Skip the loop entirely if we don't want to forward anything.
5247
if ecx.machine.communicate() || !config.forwarded_env_vars.is_empty() {
5348
for (name, value) in &config.env {
54-
// Always forward what is in `forwarded_env_vars`; that list can take precedence over excluded_env_vars.
55-
let forward = config.forwarded_env_vars.iter().any(|v| **v == *name)
56-
|| (ecx.machine.communicate()
57-
&& !excluded_env_vars.iter().any(|v| **v == *name));
49+
let forward = ecx.machine.communicate()
50+
|| config.forwarded_env_vars.iter().any(|v| **v == *name);
5851
if forward {
5952
let var_ptr = match target_os {
6053
target if target_os_is_unix(target) =>

tests/pass/concurrency/sync.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ fn check_conditional_variables_timed_wait_notimeout() {
8181
cvar.notify_one();
8282
});
8383

84-
let (_guard, timeout) = cvar.wait_timeout(guard, Duration::from_millis(1000)).unwrap();
84+
// macOS runners are very unreliable.
85+
let timeout = if cfg!(target_os = "macos") { 2000 } else { 500 };
86+
let (_guard, timeout) = cvar.wait_timeout(guard, Duration::from_millis(timeout)).unwrap();
8587
assert!(!timeout.timed_out());
8688
handle.join().unwrap();
8789
}

tests/pass/shims/env/var-exclude.rs

-5
This file was deleted.

0 commit comments

Comments
 (0)