Skip to content

Support for std::env::vars() (and ::vars_os) #936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
srijs opened this issue Aug 29, 2019 · 7 comments
Closed

Support for std::env::vars() (and ::vars_os) #936

srijs opened this issue Aug 29, 2019 · 7 comments
Labels
A-shims Area: This affects the external function shims

Comments

@srijs
Copy link

srijs commented Aug 29, 2019

Hi!

I came across an issue trying to run a proptest-based test suite via miri. proptest relies on the std::env::vars function to read a snapshot of all environment variables.

This fails on my OSX machine with the following error:

417 |     _NSGetEnviron()
    |     ^^^^^^^^^^^^^^^ Miri evaluation error: can't call foreign function: _NSGetEnviron
    |
    = note: inside call to `std::sys::unix::os::environ` at /Users/sam/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/sys/unix/os.rs:438:28
    = note: inside call to `std::sys::unix::os::env` at /Users/sam/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/env.rs:143:21
    = note: inside call to `std::env::vars_os` at /Users/sam/.cargo/registry/src/gh.loli.garden-1ecc6299db9ec823/proptest-0.9.4/src/test_runner/config.rs:78:9

Reading through the implementation of std::env::vars, it will call the _NSGetEnviron function on OSX, and on all other unix machines it will rely on an external symbol (extern char **environ) to read the environment.

Looking at the current shim code, I can see how it would be possible to implement for OSX, but it's not clear to me how you would implement this for other UNIX systems, as there doesn't seem to be an existing way in miri to hook into external symbols that are not functions.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 29, 2019

This is being worked on right now: #928

The way rustc exposes statics to us is being adjusted to support this case

@srijs
Copy link
Author

srijs commented Aug 29, 2019

Neat! Not sure how I missed that issue, thanks!

@srijs srijs closed this as completed Aug 29, 2019
@RalfJung
Copy link
Member

Well what is being worked on is the Linux version. Not sure how much extra work the macOS version needs and if @christianpoveda is up for that. ;)

@RalfJung
Copy link
Member

But indeed this is a duplicate of #756.

@srijs
Copy link
Author

srijs commented Aug 29, 2019

I'm subscribed to #756 now, and will happily tackle the OSX side of it once it works for Linux :)

@pvdrz
Copy link
Contributor

pvdrz commented Aug 29, 2019

Well what is being worked on is the Linux version. Not sure how much extra work the macOS version needs and if @christianpoveda is up for that. ;)

iirc there shouldn't be too much problem implementing this for macos after finishing linux (which will happen in the "near" future).

@pvdrz
Copy link
Contributor

pvdrz commented Aug 29, 2019

I'm subscribed to #756 now, and will happily tackle the OSX side of it once it works for Linux :)

I'll ping you when the linux implementation is done :)

@RalfJung RalfJung added the A-shims Area: This affects the external function shims label Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-shims Area: This affects the external function shims
Projects
None yet
Development

No branches or pull requests

4 participants