From 8ff4d41ba486db16446a70ef94a3d58285880358 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 28 Oct 2019 22:23:41 -0400 Subject: Don't attempt to get cwd when printing backtrace under Miri This allows Miri to print backtraces in isolation mode --- src/libstd/sys_common/backtrace.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/sys_common/backtrace.rs b/src/libstd/sys_common/backtrace.rs index 9c406ec39cc..d7296b43fbe 100644 --- a/src/libstd/sys_common/backtrace.rs +++ b/src/libstd/sys_common/backtrace.rs @@ -66,7 +66,14 @@ unsafe fn _print(w: &mut dyn Write, format: PrintFmt) -> io::Result<()> { } unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::Result { - let cwd = env::current_dir().ok(); + // Always 'fail' to get the cwd when running under Miri - + // this allows Miri to display backtraces in isolation mode + let cwd = if !cfg!(miri) { + env::current_dir().ok() + } else { + None + }; + let mut print_path = move |fmt: &mut fmt::Formatter<'_>, bows: BytesOrWideString<'_>| { output_filename(fmt, bows, print_fmt, cwd.as_ref()) }; -- cgit 1.4.1-3-g733a5