Skip to content

Commit 9fbe719

Browse files
committed
Auto merge of #937 - christianpoveda:fix-isolation, r=RalfJung
Fix cargo-miri with disabled isolation Related issue: #933 I'm not sure if that's the better place to blacklist `TERM`, @RalfJung let me know if there is a less hacky place to put it.
2 parents 0fd757e + 814fe99 commit 9fbe719

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ Several `-Z` flags are relevant for Miri:
161161
the program has access to host resources such as environment variables and
162162
randomness (and, eventually, file systems and more).
163163
* `-Zmiri-env-exclude=<var>` keeps the `var` environment variable isolated from
164-
the host. Can be used multiple times to exclude several variables.
164+
the host. Can be used multiple times to exclude several variables. The `TERM`
165+
environment variable is excluded by default.
165166
* `-Zmir-opt-level` controls how many MIR optimizations are performed. Miri
166167
overrides the default to be `0`; be advised that using any higher level can
167168
make Miri miss bugs in your program because they got optimized away.

src/shims/env.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ pub struct EnvVars {
1515
impl EnvVars {
1616
pub(crate) fn init<'mir, 'tcx>(
1717
ecx: &mut InterpCx<'mir, 'tcx, Evaluator<'tcx>>,
18-
excluded_env_vars: Vec<String>,
18+
mut excluded_env_vars: Vec<String>,
1919
) {
20+
// Exclude `TERM` var to avoid terminfo trying to open the termcap file.
21+
excluded_env_vars.push("TERM".to_owned());
22+
2023
if ecx.machine.communicate {
2124
for (name, value) in std::env::vars() {
2225
if !excluded_env_vars.contains(&name) {

test-cargo-miri/run-test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ def test_cargo_miri_test():
6060
cargo_miri("test") + ["--", "--", "le1"],
6161
"test.stdout.ref2", "test.stderr.ref"
6262
)
63+
test("cargo miri test (without isolation)",
64+
cargo_miri("test") + ["--", "-Zmiri-disable-isolation", "--", "num_cpus"],
65+
"test.stdout.ref3", "test.stderr.ref"
66+
)
6367

6468
os.chdir(os.path.dirname(os.path.realpath(__file__)))
6569

test-cargo-miri/test.stdout.ref3

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
running 0 tests
3+
4+
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out
5+
6+
7+
running 1 test
8+
test num_cpus ... ok
9+
10+
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 3 filtered out
11+

0 commit comments

Comments
 (0)