From d98ab4faf869ff0430ad73260b13ef8e473ef212 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 15 Apr 2015 12:27:05 -0700 Subject: 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 --- src/libstd/sys/unix/stack_overflow.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstd/sys/unix/stack_overflow.rs') diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 6887095c53a..2bc280d1274 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -81,7 +81,7 @@ mod imp { // We're calling into functions with stack checks stack::record_sp_limit(0); - let guard = thread_info::stack_guard(); + let guard = thread_info::stack_guard().unwrap_or(0); let addr = (*info).si_addr as usize; if guard == 0 || addr < guard - PAGE_SIZE || addr >= guard { -- cgit 1.4.1-3-g733a5