Skip to content

Commit a578be1

Browse files
committed
Auto merge of #127912 - joboet:tls_dtor_thread_current, r=cuviper
std: make `thread::current` available in all `thread_local!` destructors ... and thereby allow the panic runtime to always print the right thread name. This works by modifying the TLS destructor system to schedule a runtime cleanup function after all other TLS destructors registered by `std` have run. Unfortunately, this doesn't affect foreign TLS destructors, `thread::current` will still panic there. Additionally, the thread ID returned by `current_id` will now always be available, even inside the global allocator, and will not change during the lifetime of one thread (this was previously the case with key-based TLS). The mechanisms I added for this (`local_pointer` and `thread_cleanup`) will also allow finally fixing #111272 by moving the signal stack to a similar runtime-cleanup TLS variable.
2 parents 2176efd + 37f9d49 commit a578be1

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

tests/fail/tail_calls/cc-mismatch.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
1515
= note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at RUSTLIB/std/src/panicking.rs:LL:CC
1616
= note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panic.rs:LL:CC
1717
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
18-
= note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#2}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC
19-
= note: inside `std::panicking::r#try::<isize, {closure@std::rt::lang_start_internal::{closure#2}}>` at RUSTLIB/std/src/panicking.rs:LL:CC
20-
= note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#2}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC
18+
= note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#1}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC
19+
= note: inside `std::panicking::r#try::<isize, {closure@std::rt::lang_start_internal::{closure#1}}>` at RUSTLIB/std/src/panicking.rs:LL:CC
20+
= note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#1}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC
2121
= note: inside `std::rt::lang_start_internal` at RUSTLIB/std/src/rt.rs:LL:CC
2222
= note: inside `std::rt::lang_start::<()>` at RUSTLIB/std/src/rt.rs:LL:CC
2323

tests/pass/backtrace/backtrace-api-v0.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUSTLIB/core/src/ops/function.rs:LL:CC (std::ops::function::impls::call_once)
1010
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call)
1111
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try)
1212
RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind)
13-
RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#2})
13+
RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#1})
1414
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call)
1515
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try)
1616
RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind)

tests/pass/backtrace/backtrace-api-v1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUSTLIB/core/src/ops/function.rs:LL:CC (std::ops::function::impls::call_once)
1010
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call)
1111
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try)
1212
RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind)
13-
RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#2})
13+
RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#1})
1414
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call)
1515
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try)
1616
RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind)

tests/pass/backtrace/backtrace-global-alloc.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
at RUSTLIB/std/src/panicking.rs:LL:CC
1515
7: std::panic::catch_unwind
1616
at RUSTLIB/std/src/panic.rs:LL:CC
17-
8: std::rt::lang_start_internal::{closure#2}
17+
8: std::rt::lang_start_internal::{closure#1}
1818
at RUSTLIB/std/src/rt.rs:LL:CC
1919
9: std::panicking::r#try::do_call
2020
at RUSTLIB/std/src/panicking.rs:LL:CC

tests/pass/backtrace/backtrace-std.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
at RUSTLIB/std/src/panicking.rs:LL:CC
2323
11: std::panic::catch_unwind
2424
at RUSTLIB/std/src/panic.rs:LL:CC
25-
12: std::rt::lang_start_internal::{closure#2}
25+
12: std::rt::lang_start_internal::{closure#1}
2626
at RUSTLIB/std/src/rt.rs:LL:CC
2727
13: std::panicking::r#try::do_call
2828
at RUSTLIB/std/src/panicking.rs:LL:CC

0 commit comments

Comments
 (0)