diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-04-15 12:27:05 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-04-27 16:15:36 -0700 |
| commit | d98ab4faf869ff0430ad73260b13ef8e473ef212 (patch) | |
| tree | 22fa7775d0ea81021b825738da48498d02ea4f5d /src/libstd/thread | |
| parent | 0e154aaad6486fa8bf19b02bc3026ede0ceb91cf (diff) | |
| download | rust-d98ab4faf869ff0430ad73260b13ef8e473ef212.tar.gz rust-d98ab4faf869ff0430ad73260b13ef8e473ef212.zip | |
std: Don't assume thread::current() works on panic
Inspecting the current thread's info may not always work due to the TLS value having been destroyed (or is actively being destroyed). The code for printing a panic message assumed, however, that it could acquire the thread's name through this method. Instead this commit propagates the `Option` outwards to allow the `std::panicking` module to handle the case where the current thread isn't present. While it solves the immediate issue of #24313, there is still another underlying issue of panicking destructors in thread locals will abort the process. Closes #24313
Diffstat (limited to 'src/libstd/thread')
| -rw-r--r-- | src/libstd/thread/mod.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 383726b3e83..ce531fb1381 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -407,7 +407,9 @@ pub fn scoped<'a, T, F>(f: F) -> JoinGuard<'a, T> where /// Gets a handle to the thread that invokes it. #[stable(feature = "rust1", since = "1.0.0")] pub fn current() -> Thread { - thread_info::current_thread() + thread_info::current_thread().expect("use of std::thread::current() is not \ + possible after the thread's local \ + data has been destroyed") } /// Cooperatively gives up a timeslice to the OS scheduler. |
