Skip to content

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

Closed
@srijs

Description

@srijs

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/github.com-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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-shimsArea: This affects the external function shims

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions