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

Fix abort-on-eprintln during process shutdown #69955

Merged
merged 1 commit into from
Mar 21, 2020

Conversation

alexcrichton
Copy link
Member

This commit fixes an issue where if eprintln! is used in a TLS
destructor it can accidentally cause the process to abort. TLS
destructors are executed after main returns on the main thread, and at
this point we've also deinitialized global Lazy values like those
which store the Stderr and Stdout internals. This means that despite
handling TLS not being accessible in eprintln!, we will fail due to
not being able to call stderr(). This means that we'll double-panic
quickly because panicking also attempt to write to stderr.

The fix here is to reimplement the global stderr handle to avoid the
need for destruction. This avoids the need for Lazy as well as the
hidden panic inside of the stderr function.

Overall this should improve the robustness of printing errors and/or
panics in weird situations, since the stderr accessor should be
infallible in more situations.

@rust-highfive
Copy link
Collaborator

r? @sfackler

(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 Mar 12, 2020
@@ -70,7 +75,7 @@ impl<T> ReentrantMutex<T> {
/// If another user of this mutex panicked while holding the mutex, then
/// this call will return failure if the mutex would otherwise be
/// acquired.
pub fn lock(&self) -> LockResult<ReentrantMutexGuard<'_, T>> {
pub fn lock(&self) -> ReentrantMutexGuard<'_, T> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the poisioning here since this type is only used for one thing in libstd, I/O handles, which ignore poisoning anyway.

@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, 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.
2020-03-12T19:01:49.4170462Z ========================== Starting Command Output ===========================
2020-03-12T19:01:49.4172936Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/cc2ab8e7-f25e-4843-91fa-afc40354c8c7.sh
2020-03-12T19:01:49.4173187Z 
2020-03-12T19:01:49.4176962Z ##[section]Finishing: Disable git automatic line ending conversion
2020-03-12T19:01:49.4194955Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69955/merge to s
2020-03-12T19:01:49.4198077Z Task         : Get sources
2020-03-12T19:01:49.4198362Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-12T19:01:49.4198653Z Version      : 1.0.0
2020-03-12T19:01:49.4198842Z Author       : Microsoft
---
2020-03-12T19:01:50.4508927Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-03-12T19:01:50.4553515Z ##[command]git config gc.auto 0
2020-03-12T19:01:50.4591087Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-03-12T19:01:50.4621294Z ##[command]git config --get-all http.proxy
2020-03-12T19:01:50.4708398Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/69955/merge:refs/remotes/pull/69955/merge
---
2020-03-12T19:10:30.7349529Z configure: build.locked-deps    := True
2020-03-12T19:10:30.7350001Z configure: llvm.ccache          := sccache
2020-03-12T19:10:30.7350938Z configure: build.cargo-native-static := True
2020-03-12T19:10:30.7351627Z configure: dist.missing-tools   := True
2020-03-12T19:10:30.7352423Z configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
2020-03-12T19:10:30.7353274Z configure: writing `config.toml` in current directory
2020-03-12T19:10:30.7353627Z configure: 
2020-03-12T19:10:30.7354196Z configure: run `python /checkout/x.py --help`
2020-03-12T19:10:30.7354597Z configure: 
---
2020-03-12T19:12:21.6678985Z     Checking panic_unwind v0.0.0 (/checkout/src/libpanic_unwind)
2020-03-12T19:12:25.9001649Z error: variable does not need to be mutable
2020-03-12T19:12:25.9003359Z    --> src/libstd/sys/windows/mutex.rs:112:13
2020-03-12T19:12:25.9004330Z     |
2020-03-12T19:12:25.9005383Z 112 |         let mut re = box ReentrantMutex::uninitialized();
2020-03-12T19:12:25.9007526Z     |             |
2020-03-12T19:12:25.9008888Z     |             help: remove this `mut`
2020-03-12T19:12:25.9009845Z     |
2020-03-12T19:12:25.9010762Z     = note: `-D unused-mut` implied by `-D warnings`
---
2020-03-12T19:12:26.0688823Z   local time: Thu Mar 12 19:12:26 UTC 2020
2020-03-12T19:12:26.3591487Z   network time: Thu, 12 Mar 2020 19:12:26 GMT
2020-03-12T19:12:26.3591924Z == end clock drift check ==
2020-03-12T19:12:31.5232103Z 
2020-03-12T19:12:31.5306086Z ##[error]Bash exited with code '1'.
2020-03-12T19:12:31.5319656Z ##[section]Finishing: Run build
2020-03-12T19:12:31.5367031Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69955/merge to s
2020-03-12T19:12:31.5372209Z Task         : Get sources
2020-03-12T19:12:31.5372544Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-12T19:12:31.5372836Z Version      : 1.0.0
2020-03-12T19:12:31.5373038Z Author       : Microsoft
2020-03-12T19:12:31.5373038Z Author       : Microsoft
2020-03-12T19:12:31.5373379Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-03-12T19:12:31.5373756Z ==============================================================================
2020-03-12T19:12:31.8767727Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-03-12T19:12:31.8811871Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/69955/merge to s
2020-03-12T19:12:31.8898367Z Cleaning up task key
2020-03-12T19:12:31.8899608Z Start cleaning up orphan processes.
2020-03-12T19:12:31.9074452Z Terminate orphan process: pid (3977) (python)
2020-03-12T19:12:31.9235171Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@Mark-Simulacrum
Copy link
Member

It sounds like this might be at least related to #69558 as well, though it's a slightly different problem based on a brief skim.

@alexcrichton
Copy link
Member Author

Ah looks like that's unrelated, but still a pretty easy fix

pub unsafe fn init(&mut self) {
self.lock = UnsafeCell::new(MaybeUninit::new(AtomicU32::new(abi::LOCK_UNLOCKED.0)));
self.recursion = UnsafeCell::new(MaybeUninit::new(0));
pub unsafe fn init(&self) {
Copy link
Member

@sfackler sfackler Mar 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily related to this PR, but why is this split out to a separate method in the first place? It seems like the lock's constructor would still be able to be const without needing to go through an uninitialized stage, right?

EDIT: Nevermind, it's platform specific!

@sfackler
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Mar 12, 2020

📌 Commit 3013d5b6fcd0fda9278440deaa04a546e5076bfc has been approved by sfackler

@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 Mar 12, 2020
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, 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.
2020-03-13T00:25:51.8947122Z ========================== Starting Command Output ===========================
2020-03-13T00:25:51.8951383Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/8c03254b-4bc0-4804-b213-d541ea44742e.sh
2020-03-13T00:25:51.8951804Z 
2020-03-13T00:25:51.8956006Z ##[section]Finishing: Disable git automatic line ending conversion
2020-03-13T00:25:51.8972922Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69955/merge to s
2020-03-13T00:25:51.8975734Z Task         : Get sources
2020-03-13T00:25:51.8976004Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-13T00:25:51.8976248Z Version      : 1.0.0
2020-03-13T00:25:51.8976417Z Author       : Microsoft
---
2020-03-13T00:25:53.1582482Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-03-13T00:25:53.1589553Z ##[command]git config gc.auto 0
2020-03-13T00:25:53.1593163Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-03-13T00:25:53.1596432Z ##[command]git config --get-all http.proxy
2020-03-13T00:25:53.1604261Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/69955/merge:refs/remotes/pull/69955/merge
---
2020-03-13T01:22:00.6401082Z .................................................................................................... 1700/9767
2020-03-13T01:22:04.7674692Z .................................................................................................... 1800/9767
2020-03-13T01:22:15.3487779Z ................................................................i................................... 1900/9767
2020-03-13T01:22:21.6751323Z .................................................................................................... 2000/9767
2020-03-13T01:22:35.3095655Z ......................................................iiiii......................................... 2100/9767
2020-03-13T01:22:44.7990779Z ......................F............................................................................. 2300/9767
2020-03-13T01:22:46.8489001Z .................................................................................................... 2400/9767
2020-03-13T01:22:49.7212093Z .................................................................................................... 2500/9767
2020-03-13T01:23:09.6011579Z .................................................................................................... 2600/9767
---
2020-03-13T01:25:34.3449444Z ..........................i...............i......................................................... 5000/9767
2020-03-13T01:25:43.1856650Z .................................................................................................... 5100/9767
2020-03-13T01:25:48.3418402Z .....................................................................i.............................. 5200/9767
2020-03-13T01:25:53.8146122Z .................................................................................................... 5300/9767
2020-03-13T01:26:02.5196337Z ..................................................ii.ii........i...i................................ 5400/9767
2020-03-13T01:26:10.4190004Z .................................................................................................... 5600/9767
2020-03-13T01:26:19.4841810Z .................................................................................................... 5700/9767
2020-03-13T01:26:25.6653327Z .........................................i.......................................................... 5800/9767
2020-03-13T01:26:31.6849889Z .................................................................................................... 5900/9767
2020-03-13T01:26:31.6849889Z .................................................................................................... 5900/9767
2020-03-13T01:26:41.5803902Z .................................................................................................... 6000/9767
2020-03-13T01:26:49.7091820Z ..................................ii...i..ii...........i............................................ 6100/9767
2020-03-13T01:27:06.0126967Z .................................................................................................... 6300/9767
2020-03-13T01:27:12.5189192Z .................................................................................................... 6400/9767
2020-03-13T01:27:12.5189192Z .................................................................................................... 6400/9767
2020-03-13T01:27:21.6613546Z .................................................................i..ii.............................. 6500/9767
2020-03-13T01:27:45.1839834Z .................................................................................................... 6700/9767
2020-03-13T01:27:50.1122354Z ...............................................................i.................................... 6800/9767
2020-03-13T01:27:52.0298357Z .................................................................................................... 6900/9767
2020-03-13T01:27:54.0544023Z .................................................................................................i.. 7000/9767
---
2020-03-13T01:29:24.9880673Z .................................................................................................... 7700/9767
2020-03-13T01:29:29.1936007Z .................................................................................................... 7800/9767
2020-03-13T01:29:34.7112510Z .................................................................................................... 7900/9767
2020-03-13T01:29:40.2506953Z ...............................................i.................................................... 8000/9767
2020-03-13T01:29:49.5950346Z ................................................................................................iiii 8100/9767
2020-03-13T01:29:54.9413491Z iiiiii.i............................................................................................ 8200/9767
2020-03-13T01:30:07.9526795Z .................................................................................................... 8400/9767
2020-03-13T01:30:17.8872993Z .................................................................................................... 8500/9767
2020-03-13T01:30:29.3117448Z .................................................................................................... 8600/9767
2020-03-13T01:30:34.6412033Z .................................................................................................... 8700/9767
---
2020-03-13T01:32:05.8493571Z .......................................................................i............................ 9700/9767
2020-03-13T01:32:17.2329635Z ...................................................................
2020-03-13T01:32:17.2331941Z failures:
2020-03-13T01:32:17.2341473Z 
2020-03-13T01:32:17.2342335Z ---- [ui] ui/eprint-on-tls-drop.rs stdout ----
2020-03-13T01:32:17.2343171Z error: ui test compiled successfully!
2020-03-13T01:32:17.2343499Z status: exit code: 0
2020-03-13T01:32:17.2343499Z status: exit code: 0
2020-03-13T01:32:17.2345587Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/eprint-on-tls-drop.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eprint-on-tls-drop" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-A" "unused" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eprint-on-tls-drop/auxiliary"
2020-03-13T01:32:17.2347459Z ------------------------------------------
2020-03-13T01:32:17.2347761Z 
2020-03-13T01:32:17.2348269Z ------------------------------------------
2020-03-13T01:32:17.2348599Z stderr:
2020-03-13T01:32:17.2348599Z stderr:
2020-03-13T01:32:17.2349076Z ------------------------------------------
2020-03-13T01:32:17.2349388Z 
2020-03-13T01:32:17.2349864Z ------------------------------------------
2020-03-13T01:32:17.2350152Z 
2020-03-13T01:32:17.2350352Z 
2020-03-13T01:32:17.2350557Z 
2020-03-13T01:32:17.2350777Z failures:
2020-03-13T01:32:17.2351251Z     [ui] ui/eprint-on-tls-drop.rs
2020-03-13T01:32:17.2352162Z test result: FAILED. 9709 passed; 1 failed; 57 ignored; 0 measured; 0 filtered out
2020-03-13T01:32:17.2352544Z 
2020-03-13T01:32:17.2356203Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:348:22
2020-03-13T01:32:17.2356766Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2020-03-13T01:32:17.2356766Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2020-03-13T01:32:17.2364492Z 
2020-03-13T01:32:17.2364840Z 
2020-03-13T01:32:17.2369000Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-7/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "7.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2020-03-13T01:32:17.2373773Z 
2020-03-13T01:32:17.2373880Z 
2020-03-13T01:32:17.2374110Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2020-03-13T01:32:17.2374433Z Build completed unsuccessfully in 1:00:40
2020-03-13T01:32:17.2374433Z Build completed unsuccessfully in 1:00:40
2020-03-13T01:32:17.2423399Z == clock drift check ==
2020-03-13T01:32:17.2440406Z   local time: Fri Mar 13 01:32:17 UTC 2020
2020-03-13T01:32:17.5359242Z   network time: Fri, 13 Mar 2020 01:32:17 GMT
2020-03-13T01:32:17.5370833Z == end clock drift check ==
2020-03-13T01:32:17.9936667Z 
2020-03-13T01:32:18.0004823Z ##[error]Bash exited with code '1'.
2020-03-13T01:32:18.0017448Z ##[section]Finishing: Run build
2020-03-13T01:32:18.0064984Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69955/merge to s
2020-03-13T01:32:18.0069541Z Task         : Get sources
2020-03-13T01:32:18.0069856Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-13T01:32:18.0070135Z Version      : 1.0.0
2020-03-13T01:32:18.0070331Z Author       : Microsoft
2020-03-13T01:32:18.0070331Z Author       : Microsoft
2020-03-13T01:32:18.0070654Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-03-13T01:32:18.0071171Z ==============================================================================
2020-03-13T01:32:18.3280000Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-03-13T01:32:18.3325383Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/69955/merge to s
2020-03-13T01:32:18.3405664Z Cleaning up task key
2020-03-13T01:32:18.3406784Z Start cleaning up orphan processes.
2020-03-13T01:32:18.3745765Z Terminate orphan process: pid (5550) (python)
2020-03-13T01:32:18.3795644Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@alexcrichton
Copy link
Member Author

@bors: r=sfackler

@bors
Copy link
Contributor

bors commented Mar 13, 2020

📌 Commit 4e00b6d34236feb0fd804cc250a10bb49c493e77 has been approved by sfackler

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, 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.
2020-03-13T16:21:35.3602343Z ========================== Starting Command Output ===========================
2020-03-13T16:21:35.3606865Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/91684be0-e94a-4fa4-9b7b-96c30afc25ad.sh
2020-03-13T16:21:35.3607307Z 
2020-03-13T16:21:35.3611678Z ##[section]Finishing: Disable git automatic line ending conversion
2020-03-13T16:21:35.3628830Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69955/merge to s
2020-03-13T16:21:35.3631856Z Task         : Get sources
2020-03-13T16:21:35.3632108Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-13T16:21:35.3632352Z Version      : 1.0.0
2020-03-13T16:21:35.3632533Z Author       : Microsoft
---
2020-03-13T16:21:36.5398020Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-03-13T16:21:36.5409799Z ##[command]git config gc.auto 0
2020-03-13T16:21:36.5416512Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-03-13T16:21:36.5423249Z ##[command]git config --get-all http.proxy
2020-03-13T16:21:36.5435991Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/69955/merge:refs/remotes/pull/69955/merge
---
2020-03-13T17:23:30.7942603Z .................................................................................................... 1700/9767
2020-03-13T17:23:35.2130014Z .................................................................................................... 1800/9767
2020-03-13T17:23:47.0569295Z ................................................................i................................... 1900/9767
2020-03-13T17:23:54.2564654Z .................................................................................................... 2000/9767
2020-03-13T17:24:09.3333496Z ......................................................iiiii......................................... 2100/9767
2020-03-13T17:24:20.5399071Z .................................................................................................... 2300/9767
2020-03-13T17:24:22.7545407Z .................................................................................................... 2400/9767
2020-03-13T17:24:25.9616765Z .................................................................................................... 2500/9767
2020-03-13T17:24:47.9014978Z .................................................................................................... 2600/9767
---
2020-03-13T17:27:31.0016019Z ..........................i...............i......................................................... 5000/9767
2020-03-13T17:27:40.7586520Z .................................................................................................... 5100/9767
2020-03-13T17:27:46.6109655Z .....................................................................i.............................. 5200/9767
2020-03-13T17:27:52.4741130Z .................................................................................................... 5300/9767
2020-03-13T17:28:01.8777101Z ..................................................ii.ii........i...i................................ 5400/9767
2020-03-13T17:28:09.9831636Z .................................................................................................... 5600/9767
2020-03-13T17:28:19.6492615Z .................................................................................................... 5700/9767
2020-03-13T17:28:25.9506455Z .........................................i.......................................................... 5800/9767
2020-03-13T17:28:32.1935981Z .................................................................................................... 5900/9767
2020-03-13T17:28:32.1935981Z .................................................................................................... 5900/9767
2020-03-13T17:28:42.2785278Z .................................................................................................... 6000/9767
2020-03-13T17:28:50.9275099Z ..................................ii...i..ii...........i............................................ 6100/9767
2020-03-13T17:29:08.2180130Z .................................................................................................... 6300/9767
2020-03-13T17:29:14.7645035Z .................................................................................................... 6400/9767
2020-03-13T17:29:14.7645035Z .................................................................................................... 6400/9767
2020-03-13T17:29:25.3477443Z .................................................................i..ii.............................. 6500/9767
2020-03-13T17:29:51.5412147Z .................................................................................................... 6700/9767
2020-03-13T17:29:56.9322067Z ...............................................................i.................................... 6800/9767
2020-03-13T17:29:59.0103584Z .................................................................................................... 6900/9767
2020-03-13T17:30:01.1909521Z .................................................................................................i.. 7000/9767
---
2020-03-13T17:31:42.9732267Z .................................................................................................... 7700/9767
2020-03-13T17:31:47.4536848Z .................................................................................................... 7800/9767
2020-03-13T17:31:53.4635774Z .................................................................................................... 7900/9767
2020-03-13T17:31:59.6190491Z ...............................................i.................................................... 8000/9767
2020-03-13T17:32:09.7260256Z ................................................................................................iiii 8100/9767
2020-03-13T17:32:15.5529020Z iiiiii.i............................................................................................ 8200/9767
2020-03-13T17:32:29.7545065Z .................................................................................................... 8400/9767
2020-03-13T17:32:40.8019961Z .................................................................................................... 8500/9767
2020-03-13T17:32:53.2442157Z .................................................................................................... 8600/9767
2020-03-13T17:32:58.7620871Z .................................................................................................... 8700/9767
---
2020-03-13T17:35:17.8003407Z  finished in 7.251
2020-03-13T17:35:17.8184353Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-03-13T17:35:18.0140425Z 
2020-03-13T17:35:18.0140813Z running 179 tests
2020-03-13T17:35:21.0052458Z iiii......i...........ii..iiii....i....i...........i............i..i..................i....i........ 100/179
2020-03-13T17:35:23.3775589Z ....i.i.i...iii..iiiiiiiiiiiiiiii.......................iii............ii......
2020-03-13T17:35:23.3778471Z 
2020-03-13T17:35:23.3778635Z  finished in 5.559
2020-03-13T17:35:23.3972591Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-03-13T17:35:23.5587304Z 
---
2020-03-13T17:35:25.4080241Z  finished in 2.010
2020-03-13T17:35:25.4274713Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-03-13T17:35:25.5768438Z 
2020-03-13T17:35:25.5769873Z running 9 tests
2020-03-13T17:35:25.5771031Z iiiiiiiii
2020-03-13T17:35:25.5772189Z 
2020-03-13T17:35:25.5775895Z  finished in 0.150
2020-03-13T17:35:25.5941527Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-03-13T17:35:25.7799033Z 
---
2020-03-13T17:35:45.7323609Z  finished in 20.138
2020-03-13T17:35:45.7535204Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-03-13T17:35:45.9257001Z 
2020-03-13T17:35:45.9257744Z running 115 tests
2020-03-13T17:35:59.7113434Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii.........i.....i..i.......ii.i.ii.. 100/115
2020-03-13T17:36:01.3897556Z ...iiii.....ii.
2020-03-13T17:36:01.3901823Z 
2020-03-13T17:36:01.3905670Z  finished in 15.637
2020-03-13T17:36:01.3912523Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-03-13T17:36:01.3913258Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2020-03-13T17:49:31.3098953Z 
2020-03-13T17:49:31.3102085Z    Doc-tests core
2020-03-13T17:49:36.1571527Z 
2020-03-13T17:49:36.1572335Z running 2480 tests
2020-03-13T17:49:45.6816979Z ......iiiii......................................................................................... 100/2480
2020-03-13T17:49:54.7971641Z ....................................................................................ii.............. 200/2480
2020-03-13T17:50:15.4529959Z ...................i................................................................................ 400/2480
2020-03-13T17:50:15.4529959Z ...................i................................................................................ 400/2480
2020-03-13T17:50:25.1973204Z ........................................................................i..i..................iiii.. 500/2480
2020-03-13T17:50:41.7357291Z .................................................................................................... 700/2480
2020-03-13T17:50:50.4174264Z .................................................................................................... 800/2480
2020-03-13T17:50:59.1017909Z .................................................................................................... 900/2480
2020-03-13T17:51:07.7236345Z .................................................................................................... 1000/2480
---
2020-03-13T17:53:29.9436754Z 
2020-03-13T17:53:29.9472355Z  finished in 3.711
2020-03-13T17:53:29.9601739Z Testing std stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-03-13T17:53:30.2192357Z    Compiling std v0.0.0 (/checkout/src/libstd)
2020-03-13T17:53:43.7459725Z error[E0599]: no method named `unwrap` found for struct `sys_common::remutex::ReentrantMutexGuard<'_, ()>` in the current scope
2020-03-13T17:53:43.7462519Z     |
2020-03-13T17:53:43.7463583Z 36  | pub struct ReentrantMutexGuard<'a, T: 'a> {
2020-03-13T17:53:43.7464843Z     | ----------------------------------------- method `unwrap` not found for this
2020-03-13T17:53:43.7465723Z ...
2020-03-13T17:53:43.7465723Z ...
2020-03-13T17:53:43.7466604Z 161 |             let a = m.lock().unwrap();
2020-03-13T17:53:43.7468185Z     |                              ^^^^^^ method not found in `sys_common::remutex::ReentrantMutexGuard<'_, ()>`
2020-03-13T17:53:43.7469027Z 
2020-03-13T17:53:43.7488863Z error[E0599]: no method named `unwrap` found for struct `sys_common::remutex::ReentrantMutexGuard<'_, ()>` in the current scope
2020-03-13T17:53:43.7491004Z     |
2020-03-13T17:53:43.7491968Z 36  | pub struct ReentrantMutexGuard<'a, T: 'a> {
2020-03-13T17:53:43.7493253Z     | ----------------------------------------- method `unwrap` not found for this
2020-03-13T17:53:43.7494215Z ...
2020-03-13T17:53:43.7494215Z ...
2020-03-13T17:53:43.7495426Z 163 |                 let b = m.lock().unwrap();
2020-03-13T17:53:43.7496929Z     |                                  ^^^^^^ method not found in `sys_common::remutex::ReentrantMutexGuard<'_, ()>`
2020-03-13T17:53:43.7497726Z 
2020-03-13T17:53:43.7515389Z error[E0599]: no method named `unwrap` found for struct `sys_common::remutex::ReentrantMutexGuard<'_, ()>` in the current scope
2020-03-13T17:53:43.7517902Z     |
2020-03-13T17:53:43.7518652Z 36  | pub struct ReentrantMutexGuard<'a, T: 'a> {
2020-03-13T17:53:43.7519709Z     | ----------------------------------------- method `unwrap` not found for this
2020-03-13T17:53:43.7520440Z ...
2020-03-13T17:53:43.7520440Z ...
2020-03-13T17:53:43.7521126Z 165 |                     let c = m.lock().unwrap();
2020-03-13T17:53:43.7522381Z     |                                      ^^^^^^ method not found in `sys_common::remutex::ReentrantMutexGuard<'_, ()>`
2020-03-13T17:53:43.7523004Z 
2020-03-13T17:53:43.7586931Z error[E0599]: no method named `unwrap` found for struct `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>` in the current scope
2020-03-13T17:53:43.7588607Z     |
2020-03-13T17:53:43.7589360Z 36  | pub struct ReentrantMutexGuard<'a, T: 'a> {
2020-03-13T17:53:43.7590694Z     | ----------------------------------------- method `unwrap` not found for this
2020-03-13T17:53:43.7591394Z ...
2020-03-13T17:53:43.7591394Z ...
2020-03-13T17:53:43.7592049Z 178 |         let lock = m.lock().unwrap();
2020-03-13T17:53:43.7593367Z     |                             ^^^^^^ method not found in `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>`
2020-03-13T17:53:43.7594040Z 
2020-03-13T17:53:43.7615757Z error[E0599]: no method named `unwrap` found for struct `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>` in the current scope
2020-03-13T17:53:43.7617412Z     |
2020-03-13T17:53:43.7618350Z 36  | pub struct ReentrantMutexGuard<'a, T: 'a> {
2020-03-13T17:53:43.7619481Z     | ----------------------------------------- method `unwrap` not found for this
2020-03-13T17:53:43.7620175Z ...
2020-03-13T17:53:43.7620175Z ...
2020-03-13T17:53:43.7620867Z 180 |             let lock = m2.lock().unwrap();
2020-03-13T17:53:43.7622188Z     |                                  ^^^^^^ method not found in `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>`
2020-03-13T17:53:43.7622876Z 
2020-03-13T17:53:43.7661583Z error[E0599]: no method named `unwrap` found for struct `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>` in the current scope
2020-03-13T17:53:43.7663282Z     |
2020-03-13T17:53:43.7664045Z 36  | pub struct ReentrantMutexGuard<'a, T: 'a> {
2020-03-13T17:53:43.7665100Z     | ----------------------------------------- method `unwrap` not found for this
2020-03-13T17:53:43.7665814Z ...
2020-03-13T17:53:43.7665814Z ...
2020-03-13T17:53:43.7666483Z 184 |             let lock = m.lock().unwrap();
2020-03-13T17:53:43.7667794Z     |                                 ^^^^^^ method not found in `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>`
2020-03-13T17:53:43.7668502Z 
2020-03-13T17:53:43.7707536Z error[E0599]: no method named `is_err` found for enum `core::option::Option<sys_common::remutex::ReentrantMutexGuard<'_, ()>>` in the current scope
2020-03-13T17:53:43.7709198Z     |
2020-03-13T17:53:43.7709198Z     |
2020-03-13T17:53:43.7709873Z 199 |             assert!(lock.is_err());
2020-03-13T17:53:43.7711150Z     |                          ^^^^^^ method not found in `core::option::Option<sys_common::remutex::ReentrantMutexGuard<'_, ()>>`
2020-03-13T17:53:43.7711867Z 
2020-03-13T17:53:43.7752075Z error[E0599]: no method named `unwrap` found for struct `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>` in the current scope
2020-03-13T17:53:43.7753973Z     |
2020-03-13T17:53:43.7754729Z 36  | pub struct ReentrantMutexGuard<'a, T: 'a> {
2020-03-13T17:53:43.7755808Z     | ----------------------------------------- method `unwrap` not found for this
2020-03-13T17:53:43.7756502Z ...
2020-03-13T17:53:43.7756502Z ...
2020-03-13T17:53:43.7757173Z 218 |             let lock = mc.lock().unwrap();
2020-03-13T17:53:43.7758514Z     |                                  ^^^^^^ method not found in `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>`
2020-03-13T17:53:43.7759200Z 
2020-03-13T17:53:43.7783010Z error[E0599]: no method named `unwrap` found for struct `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>` in the current scope
2020-03-13T17:53:43.7788988Z     |
2020-03-13T17:53:43.7789781Z 36  | pub struct ReentrantMutexGuard<'a, T: 'a> {
2020-03-13T17:53:43.7790874Z     | ----------------------------------------- method `unwrap` not found for this
2020-03-13T17:53:43.7791572Z ...
2020-03-13T17:53:43.7791572Z ...
2020-03-13T17:53:43.7792268Z 220 |             let lock2 = mc.lock().unwrap();
2020-03-13T17:53:43.7793607Z     |                                   ^^^^^^ method not found in `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>`
2020-03-13T17:53:43.7794305Z 
2020-03-13T17:53:44.5665990Z error[E0599]: no method named `err` found for struct `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>` in the current scope
2020-03-13T17:53:44.5667663Z     |
2020-03-13T17:53:44.5668435Z 36  | pub struct ReentrantMutexGuard<'a, T: 'a> {
2020-03-13T17:53:44.5669488Z     | ----------------------------------------- method `err` not found for this
2020-03-13T17:53:44.5670172Z ...
2020-03-13T17:53:44.5670172Z ...
2020-03-13T17:53:44.5670894Z 227 |         let r = m.lock().err().unwrap().into_inner();
2020-03-13T17:53:44.5672229Z     |                          ^^^ method not found in `sys_common::remutex::ReentrantMutexGuard<'_, core::cell::RefCell<{integer}>>`
2020-03-13T17:53:44.7310512Z error: aborting due to 10 previous errors
2020-03-13T17:53:44.7311418Z 
2020-03-13T17:53:44.7312289Z For more information about this error, try `rustc --explain E0599`.
2020-03-13T17:53:44.7484240Z error: could not compile `std`.
---
2020-03-13T17:53:44.7587000Z   local time: Fri Mar 13 17:53:44 UTC 2020
2020-03-13T17:53:45.0562389Z   network time: Fri, 13 Mar 2020 17:53:45 GMT
2020-03-13T17:53:45.0566865Z == end clock drift check ==
2020-03-13T17:53:45.5561340Z 
2020-03-13T17:53:45.5640044Z ##[error]Bash exited with code '1'.
2020-03-13T17:53:45.5655736Z ##[section]Finishing: Run build
2020-03-13T17:53:45.5712725Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69955/merge to s
2020-03-13T17:53:45.5718651Z Task         : Get sources
2020-03-13T17:53:45.5719049Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-13T17:53:45.5719427Z Version      : 1.0.0
2020-03-13T17:53:45.5719681Z Author       : Microsoft
2020-03-13T17:53:45.5719681Z Author       : Microsoft
2020-03-13T17:53:45.5720118Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-03-13T17:53:45.5720599Z ==============================================================================
2020-03-13T17:53:45.8975106Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-03-13T17:53:45.9016924Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/69955/merge to s
2020-03-13T17:53:45.9096939Z Cleaning up task key
2020-03-13T17:53:45.9098021Z Start cleaning up orphan processes.
2020-03-13T17:53:45.9265007Z Terminate orphan process: pid (3909) (python)
2020-03-13T17:53:45.9482311Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@alexcrichton
Copy link
Member Author

@bors: r=sfackler

@bors
Copy link
Contributor

bors commented Mar 13, 2020

📌 Commit 8c734a51ac17b4638b0e6e7b7b60a05bf00dd9c1 has been approved by sfackler

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, 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.
2020-03-13T19:50:27.6802344Z ========================== Starting Command Output ===========================
2020-03-13T19:50:27.6806911Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/dc7a94af-f746-42e2-bf15-d604616cc1fc.sh
2020-03-13T19:50:27.6807366Z 
2020-03-13T19:50:27.6811381Z ##[section]Finishing: Disable git automatic line ending conversion
2020-03-13T19:50:27.6828153Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/69955/merge to s
2020-03-13T19:50:27.6831464Z Task         : Get sources
2020-03-13T19:50:27.6831861Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-03-13T19:50:27.6832083Z Version      : 1.0.0
2020-03-13T19:50:27.6832276Z Author       : Microsoft
---
2020-03-13T19:50:28.9418467Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-03-13T19:50:28.9490026Z ##[command]git config gc.auto 0
2020-03-13T19:50:28.9497254Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-03-13T19:50:28.9502793Z ##[command]git config --get-all http.proxy
2020-03-13T19:50:28.9510737Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/69955/merge:refs/remotes/pull/69955/merge

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 @rust-lang/infra. (Feature Requests)

@alexcrichton
Copy link
Member Author

@bors: r=sfackler

@bors
Copy link
Contributor

bors commented Mar 13, 2020

📌 Commit c274e07 has been approved by sfackler

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 14, 2020
…fackler

Fix abort-on-eprintln during process shutdown

This commit fixes an issue where if `eprintln!` is used in a TLS
destructor it can accidentally cause the process to abort. TLS
destructors are executed after `main` returns on the main thread, and at
this point we've also deinitialized global `Lazy` values like those
which store the `Stderr` and `Stdout` internals. This means that despite
handling TLS not being accessible in `eprintln!`, we will fail due to
not being able to call `stderr()`. This means that we'll double-panic
quickly because panicking also attempt to write to stderr.

The fix here is to reimplement the global stderr handle to avoid the
need for destruction. This avoids the need for `Lazy` as well as the
hidden panic inside of the `stderr` function.

Overall this should improve the robustness of printing errors and/or
panics in weird situations, since the `stderr` accessor should be
infallible in more situations.
@bors
Copy link
Contributor

bors commented Mar 17, 2020

📌 Commit a4cbcb2 has been approved by sfackler

@bors
Copy link
Contributor

bors commented Mar 17, 2020

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 17, 2020
…fackler

Fix abort-on-eprintln during process shutdown

This commit fixes an issue where if `eprintln!` is used in a TLS
destructor it can accidentally cause the process to abort. TLS
destructors are executed after `main` returns on the main thread, and at
this point we've also deinitialized global `Lazy` values like those
which store the `Stderr` and `Stdout` internals. This means that despite
handling TLS not being accessible in `eprintln!`, we will fail due to
not being able to call `stderr()`. This means that we'll double-panic
quickly because panicking also attempt to write to stderr.

The fix here is to reimplement the global stderr handle to avoid the
need for destruction. This avoids the need for `Lazy` as well as the
hidden panic inside of the `stderr` function.

Overall this should improve the robustness of printing errors and/or
panics in weird situations, since the `stderr` accessor should be
infallible in more situations.
@ehuss
Copy link
Contributor

ehuss commented Mar 18, 2020

@bors r-
This also fails on wasm32-unknown-unknown

---- [ui] ui/eprint-on-tls-drop.rs stdout ----
stderr:
------------------------------------------
RuntimeError: unreachable
    at __rust_start_panic (wasm-function[122]:1)
    at rust_panic (wasm-function[43]:39)
    at _ZN3std9panicking20rust_panic_with_hook17he47b91edb8082eabE (wasm-function[38]:279)
    at rust_begin_unwind (wasm-function[37]:84)
    at _ZN4core9panicking9panic_fmt17he18e83d766016c7aE (wasm-function[178]:58)
    at _ZN4core6result13unwrap_failed17h9fc1fc3320bec770E (wasm-function[149]:139)
    at _ZN4core6result19Result$LT$T$C$E$GT$6unwrap17h708bda3f34d3945bE (wasm-function[2]:67)
    at _ZN18eprint_on_tls_drop4main17he6677df84c8c9a17E (wasm-function[3]:106)
    at _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hcb9c038157d3e6aeE (wasm-function[5]:25)
    at _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h1d562f1bc2cf93c6E (wasm-function[114]:8)
    at _ZN3std9panicking3try7do_call17h7e855ca6cb87c0f9E.llvm.9727205892680777974 (wasm-function[36]:20)
    at __rust_maybe_catch_panic (wasm-function[121]:5)
    at _ZN3std2rt19lang_start_internal17h32edf9b2fff1c357E (wasm-function[66]:125)
    at main (wasm-function[4]:46)
    at Object.<anonymous> (/Users/eric/Proj/rust/rust/src/etc/wasm32-shim.js:20:20)
    at Module._compile (internal/modules/cjs/loader.js:868:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
    at Module.load (internal/modules/cjs/loader.js:731:32)
    at Function.Module._load (internal/modules/cjs/loader.js:644:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:931:10)

@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 Mar 18, 2020
@alexcrichton
Copy link
Member Author

@bors: r=sfackler

@bors
Copy link
Contributor

bors commented Mar 18, 2020

📌 Commit 2c22da0 has been approved by sfackler

@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 18, 2020
Centril added a commit to Centril/rust that referenced this pull request Mar 19, 2020
…fackler

Fix abort-on-eprintln during process shutdown

This commit fixes an issue where if `eprintln!` is used in a TLS
destructor it can accidentally cause the process to abort. TLS
destructors are executed after `main` returns on the main thread, and at
this point we've also deinitialized global `Lazy` values like those
which store the `Stderr` and `Stdout` internals. This means that despite
handling TLS not being accessible in `eprintln!`, we will fail due to
not being able to call `stderr()`. This means that we'll double-panic
quickly because panicking also attempt to write to stderr.

The fix here is to reimplement the global stderr handle to avoid the
need for destruction. This avoids the need for `Lazy` as well as the
hidden panic inside of the `stderr` function.

Overall this should improve the robustness of printing errors and/or
panics in weird situations, since the `stderr` accessor should be
infallible in more situations.
@Dylan-DPC-zz
Copy link

Failed in rollup #70141 on android

@bors r-

@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 Mar 19, 2020
This commit fixes an issue where if `eprintln!` is used in a TLS
destructor it can accidentally cause the process to abort. TLS
destructors are executed after `main` returns on the main thread, and at
this point we've also deinitialized global `Lazy` values like those
which store the `Stderr` and `Stdout` internals. This means that despite
handling TLS not being accessible in `eprintln!`, we will fail due to
not being able to call `stderr()`. This means that we'll double-panic
quickly because panicking also attempt to write to stderr.

The fix here is to reimplement the global stderr handle to avoid the
need for destruction. This avoids the need for `Lazy` as well as the
hidden panic inside of the `stderr` function.

Overall this should improve the robustness of printing errors and/or
panics in weird situations, since the `stderr` accessor should be
infallible in more situations.
@alexcrichton
Copy link
Member Author

@bors: r=sfackler

@bors
Copy link
Contributor

bors commented Mar 20, 2020

📌 Commit 5edaa7e has been approved by sfackler

@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 20, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 21, 2020
Rollup of 6 pull requests

Successful merges:

 - rust-lang#69497 (Don't unwind when hitting the macro expansion recursion limit)
 - rust-lang#69901 (add #[rustc_layout(debug)])
 - rust-lang#69910 (Avoid query type in generics)
 - rust-lang#69955 (Fix abort-on-eprintln during process shutdown)
 - rust-lang#70032 (put type params in front of const params in generics_of)
 - rust-lang#70119 (rustc: use LocalDefId instead of DefId in TypeckTables.)

Failed merges:

r? @ghost
@bors bors merged commit 276b54e into rust-lang:master Mar 21, 2020
@alexcrichton alexcrichton deleted the stderr-infallible branch July 23, 2020 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

9 participants