Skip to content
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

test that build scripts do not run in Miri #930

Merged
merged 2 commits into from
Aug 28, 2019
Merged

Conversation

RalfJung
Copy link
Member

@elichai reported something that sounded a lot like build script running in Miri. But as this test shows, build scripts are not run by Miri, they are run normally.

@elichai are you sure the env var usage you were referring to was only in a build script? Those shouldn't be affected by Miri flags at all. Is your code available somewhere so that I can try to reproduce?

test-cargo-miri/Cargo.toml Outdated Show resolved Hide resolved
@elichai
Copy link
Contributor

elichai commented Aug 28, 2019

Hmm. SO I got rid of everything std related I have, both in build.rs and in the code and i'm still getting that Miri evaluation error: can't call foreign function: stat64 error. and only when enabling -Zmiri-disable-isolation (just updated miri to the latest nightly)

I'll try creating a new isolated library to give you as an example

@elichai
Copy link
Contributor

elichai commented Aug 28, 2019

This happens even on an empty library:

elichai2@nphard-core:~/gits $ mkdir something
elichai2@nphard-core:~/gits $ cd something/
elichai2@nphard-core:~/gits/something $ cargo init --lib
     Created library package
elichai2@nphard-core:~/gits/something $ cargo +nightly miri test -- -Zmiri-disable-isolation
   Compiling something v0.1.0 (/home/elichai2/gits/something)
error[E0080]: Miri evaluation error: can't call foreign function: stat64
   --> /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/sys/unix/fs.rs:803:9
    |
803 |         stat64(p.as_ptr(), &mut stat)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Miri evaluation error: can't call foreign function: stat64
    |
    = note: inside call to `std::sys::unix::fs::stat` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/fs.rs:1516:5
    = note: inside call to `std::fs::metadata::<&std::path::PathBuf>` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libterm/terminfo/searcher.rs:50:12
    = note: inside call to `term::terminfo::searcher::get_dbpath_for_term` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libterm/terminfo/mod.rs:87:9
    = note: inside call to `term::terminfo::TermInfo::from_name` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libterm/terminfo/mod.rs:73:25
    = note: inside call to `term::terminfo::TermInfo::from_env` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libterm/terminfo/mod.rs:232:9
    = note: inside call to `term::terminfo::TerminfoTerminal::<std::io::Stdout>::new` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libterm/lib.rs:61:5
    = note: inside call to `term::stdout` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:921:24
    = note: inside call to `tests::test::run_tests_console` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:295:15
    = note: inside call to `tests::test::test_main` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:329:5
    = note: inside call to `tests::test::test_main_static`
    = note: inside call to `main` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:64:34
    = note: inside call to closure at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:52:53
    = note: inside call to closure at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:296:40
    = note: inside call to `std::panicking::try::do_call::<[closure@DefId(1:5914 ~ std[65ee]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:292:5
    = note: inside call to `std::panicking::try::<i32, [closure@DefId(1:5914 ~ std[65ee]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe]>` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:394:9
    = note: inside call to `std::panic::catch_unwind::<[closure@DefId(1:5914 ~ std[65ee]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:52:25
    = note: inside call to `std::rt::lang_start_internal` at /home/elichai2/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:64:5
    = note: inside call to `std::rt::lang_start::<()>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
error: Could not compile `something`.

To learn more, run the command again with --verbose.

elichai2@nphard-core:~/gits/something $ cargo +nightly miri test
   Compiling something v0.1.0 (/home/elichai2/gits/something)

running 1 test
test tests::it_works ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

    Finished dev [unoptimized + debuginfo] target(s) in 0.74s

elichai2@nphard-core:~/gits/something $ rustc -V
rustc 1.39.0-nightly (53df91a9b 2019-08-27)
elichai2@nphard-core:~/gits/something $ cargo -V
cargo 1.39.0-nightly (3f700ec43 2019-08-19)

@bjorn3
Copy link
Member

bjorn3 commented Aug 28, 2019

It seems terminfo tried to read the termcap file.

@RalfJung
Copy link
Member Author

RalfJung commented Aug 28, 2019

This happens even on an empty library:

Interesting, I cannot reproduce. Which OS/distro/version is that?
EDIT: Oh actually I can. Very intersting. Will open an issue.

Also let's merge this test here -- your problem doesn't seem to have anything to do with build scripts but whatever.
@bors r+

@bors
Copy link
Contributor

bors commented Aug 28, 2019

📌 Commit 7faa329 has been approved by RalfJung

@bors
Copy link
Contributor

bors commented Aug 28, 2019

⌛ Testing commit 7faa329 with merge 1f46c51...

bors added a commit that referenced this pull request Aug 28, 2019
test that build scripts do not run in Miri

@elichai reported something that sounded a lot like build script running in Miri. But as this test shows, build scripts are not run by Miri, they are run normally.

@elichai are you sure the [env var usage you were referring to](#641 (comment)) was only in a build script? Those shouldn't be affected by Miri flags at all. Is your code available somewhere so that I can try to reproduce?
@bors

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Aug 28, 2019

📌 Commit 7faa329 has been approved by RalfJung

@bors
Copy link
Contributor

bors commented Aug 28, 2019

⌛ Testing commit 7faa329 with merge 61f9db2...

bors added a commit that referenced this pull request Aug 28, 2019
test that build scripts do not run in Miri

@elichai reported something that sounded a lot like build script running in Miri. But as this test shows, build scripts are not run by Miri, they are run normally.

@elichai are you sure the [env var usage you were referring to](#641 (comment)) was only in a build script? Those shouldn't be affected by Miri flags at all. Is your code available somewhere so that I can try to reproduce?
@bors

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Aug 28, 2019

📌 Commit 7faa329 has been approved by RalfJung

@bors
Copy link
Contributor

bors commented Aug 28, 2019

⌛ Testing commit 7faa329 with merge 2661580...

bors added a commit that referenced this pull request Aug 28, 2019
test that build scripts do not run in Miri

@elichai reported something that sounded a lot like build script running in Miri. But as this test shows, build scripts are not run by Miri, they are run normally.

@elichai are you sure the [env var usage you were referring to](#641 (comment)) was only in a build script? Those shouldn't be affected by Miri flags at all. Is your code available somewhere so that I can try to reproduce?
@RalfJung
Copy link
Member Author

Opened an issue: #933

@bors
Copy link
Contributor

bors commented Aug 28, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: RalfJung
Pushing 2661580 to master...

@bors bors merged commit 7faa329 into rust-lang:master Aug 28, 2019
@RalfJung RalfJung deleted the build branch August 29, 2019 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants