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

Use the correct stderr when testing libstd #58464

Merged
merged 1 commit into from
Mar 3, 2019

Conversation

jethrogb
Copy link
Contributor

When compiling the unit tests for libstd, there are two copies of std in existence, see lib.rs. This means there are two copies of everything, including thread local variable definitions. Before this PR, it's possible that libtest would configure a stderr sink in one of those copies, whereas the panic logic would inspect the sink in the other copy, resulting in libtest missing the relevant panic message. This PR makes sure that when testing, the panic logic always accesses the stderr sink from “realstd”, using the same logic that libtest uses.

@rust-highfive
Copy link
Collaborator

r? @dtolnay

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 14, 2019
@jethrogb jethrogb changed the title [WIP] Use the correct stderr when testing libstd Use the correct stderr when testing libstd Feb 14, 2019
@jethrogb jethrogb force-pushed the jb/std-test-panic-output branch from 0576512 to 8e9ff92 Compare February 14, 2019 13:14
@dtolnay
Copy link
Member

dtolnay commented Feb 14, 2019

Seems okay to me but let me get a review from someone who may be more familiar with the std/realstd situation.

r? @alexcrichton

@alexcrichton
Copy link
Member

Could the impl block forwarding from std to realstd be extracted to a more prominent location and commented? Other than that r=me

@jethrogb
Copy link
Contributor Author

Which location do you have in mind? Next to extern crate realstd in lib.rs? Next to the other Write trait implementations? The specific impl for Box<dyn (::realstd::io::Write) + Send> is quite specialized to make sure write(&mut local); on the following line works in both cases, but I suppose I could mention this in the comment.

@jethrogb
Copy link
Contributor Author

I'm also going to re-export stdio::_print and stdio::_eprint from realstd, so that print/eprint get captured correctly as well.

@alexcrichton
Copy link
Member

Something like std::io seems like a good spot perhaps? If enough of these shims show up we could also have a dedicated module for it.

@jethrogb jethrogb force-pushed the jb/std-test-panic-output branch from 8e9ff92 to 39b6766 Compare February 20, 2019 01:44
@jethrogb
Copy link
Contributor Author

Pushed changes.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0c4d6e38:start=1550627163113357485,finish=1550627251407446873,duration=88294089388
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:08:41] 
[01:08:41] running 119 tests
[01:09:05] .iiiii...i.....i..i...i..i.i..i.ii...i.....i..i....i..........iiii..........i...ii...i.......ii.i.i. 100/119
[01:09:09] i......iii.i.....ii
[01:09:09] 
[01:09:09]  finished in 28.295
[01:09:09] travis_fold:end:test_debuginfo

---
[01:24:10] travis_fold:start:test_stage1-std
travis_time:start:test_stage1-std
Testing std stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:24:10]    Compiling std v0.0.0 (/checkout/src/libstd)
[01:24:14] error[E0658]: use of unstable library feature 'print_internals': implementation detail which may disappear or be replaced at any time
[01:24:14]    --> src/libstd/io/mod.rs:284:23
[01:24:14]     |
[01:24:14] 284 | pub use self::stdio::{_print, _eprint};
[01:24:14]     |
[01:24:14]     = help: add #![feature(print_internals)] to the crate attributes to enable
[01:24:14] 
[01:24:14] 
[01:24:14] error[E0658]: use of unstable library feature 'print_internals': implementation detail which may disappear or be replaced at any time
[01:24:14]    --> src/libstd/io/mod.rs:284:31
[01:24:14]     |
[01:24:14] 284 | pub use self::stdio::{_print, _eprint};
[01:24:14]     |
[01:24:14]     = help: add #![feature(print_internals)] to the crate attributes to enable
[01:24:14] 
[01:24:14] 
[01:24:14] error[E0658]: use of unstable library feature 'print_internals': implementation detail which may disappear or be replaced at any time
[01:24:14]     |
[01:24:14]     |
[01:24:14] 764 | pub use realstd::io::{_eprint, _print};
[01:24:14]     |
[01:24:14]     = help: add #![feature(print_internals)] to the crate attributes to enable
[01:24:14] 
[01:24:14] 
[01:24:14] error[E0658]: use of unstable library feature 'print_internals': implementation detail which may disappear or be replaced at any time
[01:24:14]     |
[01:24:14]     |
[01:24:14] 764 | pub use realstd::io::{_eprint, _print};
[01:24:14]     |
[01:24:14]     = help: add #![feature(print_internals)] to the crate attributes to enable
[01:24:14] 
[01:24:22] error: aborting due to 4 previous errors
[01:24:22] error: aborting due to 4 previous errors
[01:24:22] 
[01:24:22] For more information about this error, try `rustc --explain E0658`.
[01:24:22] error: Could not compile `std`.
[01:24:22] 
[01:24:22] To learn more, run the command again with --verbose.
[01:24:22] 
[01:24:22] 
[01:24:22] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "std" "--" "--quiet"
[01:24:22] 
[01:24:22] 
[01:24:22] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:24:22] Build completed unsuccessfully in 0:26:53
[01:24:22] Build completed unsuccessfully in 0:26:53
[01:24:22] make: *** [check] Error 1
[01:24:22] Makefile:48: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:01bdb256
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Wed Feb 20 03:12:01 UTC 2019

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@jethrogb jethrogb force-pushed the jb/std-test-panic-output branch from 39b6766 to 7f66d10 Compare February 20, 2019 06:49
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:13fb9648:start=1550645470308470394,finish=1550645566607705667,duration=96299235273
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
travis_time:start:test_codegen
Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:08:38] 
[01:08:38] running 130 tests
[01:08:41] i..iii...i.ii.iiii.....i.................i..i................i.....i.........ii...i..i.ii........... 100/130
[01:08:42] test result: ok. 101 passed; 0 failed; 29 ignored; 0 measured; 0 filtered out
[01:08:42] 
[01:08:42]  finished in 3.977
[01:08:42] travis_fold:end:test_codegen
---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:08:58] 
[01:08:58] running 119 tests
[01:09:22] .iiiii...i.....i..i...i..i.i..i.ii...i.....i..i....i..........iiii..........i...ii...i.......ii.i.i. 100/119
[01:09:27] i......iii.i.....ii
[01:09:27] 
[01:09:27]  finished in 28.345
[01:09:27] travis_fold:end:test_debuginfo

---
[01:23:57]    Compiling std v0.0.0 (/checkout/src/libstd)
[01:24:16] error: function is never used: `print_to`
[01:24:16]    --> src/libstd/io/stdio.rs:720:1
[01:24:16]     |
[01:24:16] 720 | / fn print_to<T>(
[01:24:16] 721 | |     args: fmt::Arguments,
[01:24:16] 722 | |     local_s: &'static LocalKey<RefCell<Option<Box<dyn Write+Send>>>>,
[01:24:16] 723 | |     global_s: fn() -> T,
[01:24:16] 742 | |     }
[01:24:16] 743 | | }
[01:24:16]     | |_^
[01:24:16]     |
---
[01:24:17] 
[01:24:17] To learn more, run the command again with --verbose.
[01:24:17] 
[01:24:17] 
[01:24:17] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "std" "--" "--quiet"
[01:24:17] 
[01:24:17] 
[01:24:17] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:24:17] Build completed unsuccessfully in 0:26:26
[01:24:17] Build completed unsuccessfully in 0:26:26
[01:24:17] make: *** [check] Error 1
[01:24:17] Makefile:48: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:06cd56c0
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Wed Feb 20 08:17:12 UTC 2019
---
travis_time:end:05241d78:start=1550650634245243828,finish=1550650634250075912,duration=4832084
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:01299281
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:03b56fad
travis_time:start:03b56fad
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:322a16b0
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@jethrogb jethrogb force-pushed the jb/std-test-panic-output branch 2 times, most recently from ef0b1f9 to 78602ff Compare February 20, 2019 08:54
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Feb 20, 2019

📌 Commit 78602ffff806d8f0d218e870db10d016852bfec8 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 20, 2019
@bors
Copy link
Contributor

bors commented Feb 23, 2019

☔ The latest upstream changes (presumably #58644) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 23, 2019
@Centril
Copy link
Contributor

Centril commented Feb 23, 2019

Ping from triage, @jethrogb seems like this needs some rebasing.

@jethrogb
Copy link
Contributor Author

Rebased

@jethrogb jethrogb force-pushed the jb/std-test-panic-output branch from 78602ff to 3fa7c49 Compare February 26, 2019 00:14
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Feb 26, 2019

📌 Commit 3fa7c49304aab5170c9a6f77f330f00a3bbf2043 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 26, 2019
@bors
Copy link
Contributor

bors commented Feb 28, 2019

☔ The latest upstream changes (presumably #58208) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 28, 2019
@jethrogb jethrogb force-pushed the jb/std-test-panic-output branch from 3fa7c49 to 23fefe8 Compare March 1, 2019 03:01
@jethrogb
Copy link
Contributor Author

jethrogb commented Mar 1, 2019

Rebased

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:11685c84:start=1551409350605865449,finish=1551409351512539950,duration=906674501
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
travis_time:end:021a21ec:start=1551409662359168725,finish=1551409662363793958,duration=4625233
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:2d331908
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0a2202a4
travis_time:start:0a2202a4
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0a77b070
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@jethrogb jethrogb force-pushed the jb/std-test-panic-output branch from 23fefe8 to c0e8cf9 Compare March 1, 2019 03:09
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Mar 1, 2019

📌 Commit c0e8cf9 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 1, 2019
@bors
Copy link
Contributor

bors commented Mar 3, 2019

⌛ Testing commit c0e8cf9 with merge 7dbba3d...

bors added a commit that referenced this pull request Mar 3, 2019
Use the correct stderr when testing libstd

When compiling the unit tests for libstd, there are two copies of `std` in existence, see [lib.rs](https://github.com/rust-lang/rust/blob/919cf42/src/libstd/lib.rs#L335-L341). This means there are two copies of everything, including thread local variable definitions. Before this PR, it's possible that libtest would configure a stderr sink in one of those copies, whereas the panic logic would inspect the sink in the other copy, resulting in libtest missing the relevant panic message. This PR makes sure that when testing, the panic logic always accesses the stderr sink from “realstd”, using the same logic that libtest uses.
@bors
Copy link
Contributor

bors commented Mar 3, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: alexcrichton
Pushing 7dbba3d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 3, 2019
@bors bors merged commit c0e8cf9 into rust-lang:master Mar 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants