miri: Improve handling of failed operations in isolation mode

Currently, we abort program execution when we try to access the external environment in isolation mode. However, libstd currently calls getcwd when printing out a panic backtrace. To ensure that panicking works in isolation mode, we’ve disabled the call to getcwd when libstd has cfg(miri) enabled.

Eventually, it would be good to remove this hack, and start returning proper error codes from disabled functions, rather than aborting the process.

See https://github.com/rust-lang/rust/pull/60026#discussion_r342257352 for more discussion

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 21 (18 by maintainers)

Commits related to this issue

Most upvoted comments

I guess most of the fs operations can return EPERM.

Hi @RalfJung , I opened a PR fixing get and set cwd ops. Let me know what you think. Also, this is my first PR in rustc related packages. If you find something missing from the usual workflow, please let me know 🙂

@henryboisdequin I never ended up getting to this, so you can try!

I’m going to try working on this.

Here’s another example where it would be good if isolated operations returned failure instead of aborting execution: https://github.com/seanmonstar/num_cpus/pull/96 makes num_cpus open a file (rejected with isolation) but falls back to another way of determining the CPU count (which works in isolation).