Add helper 'alloc_os_str_as_c_str' and use it in env_var emulation
First part of the plan laid out in #707 (comment).
Re-submitting a pull-request for work from #1098 (manual rebasing..)
r? @RalfJung
support main functions with Result return type
Turns out we already properly create the substitution to call the libstd start-fn with an appropriate `main`, we just had an overzealous check in the way.
Fixes https://github.com/rust-lang/miri/issues/1116.
Add statx shim for linux target
This is an attempt to fix: https://github.com/rust-lang/miri/issues/999 (for linux only)
Currently there is one problem that I haven't been able to solve. `std::fs::metadata` fails because the creation time is not available even though it is provided in the shim code.
In order to inform the caller that the field was provided, the `stx_flag` field must have the bits of `STATX_BTIME` set (which they are). The creation time is in the `stx_btime` field of the `statx` struct (see [1]). The relevant code in `libstd` is here (probably?): https://github.com/rust-lang/rust/blob/master/src/libstd/sys/unix/fs.rs#L322
Another important point is that we are just providing the fields that are available in "all" platforms (this is, without using any platform specific traits or so). This can be improved later.
References:
[1] Man page: http://man7.org/linux/man-pages/man2/statx.2.html
[2] libc `statx` struct: https://docs.rs/libc/0.2.63/libc/struct.statx.html
Edit: The problem is that my filesystem is not providing it and I thought all filesystems could provide it. I changed the code so it only provides those dates if they are available. now we are ready to go.
r? @RalfJung @oli-obk
Add a scheme to find the place where an id was destroyed
cc https://github.com/rust-lang/miri/issues/974
I'm not too happy with it, but since stacked borrows don't have access to the current call stack, I can't just report a warning as per https://github.com/rust-lang/miri/issues/797
We could add some global mutex that we can throw strings at and `step` will clear out that mutex and report warnings before moving the `statement_id` or the `block_id`, not sure how well that would work. For now I think this is sufficient