Panic when the global allocator tries to register a TLS destructor by joboet · Pull Request #116402 · rust-lang/rust
labels
Oct 3, 2023
bors
added
S-waiting-on-bors
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.labels
Oct 4, 2023matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
Oct 5, 2023…s, r=thomcc Panic when the global allocator tries to register a TLS destructor Using a `RefCell` avoids the undefined behaviour encountered in rust-lang#116390 and reduces the amount of `unsafe` code in the codebase.
bors added a commit to rust-lang-ci/rust that referenced this pull request
Oct 5, 2023…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#116223 (Fix misuses of a vs an) - rust-lang#116296 (More accurately point to where default return type should go) - rust-lang#116402 (Panic when the global allocator tries to register a TLS destructor) - rust-lang#116429 (Diagnostics: Be more careful when suggesting struct fields) - rust-lang#116431 (Tweak wording of E0562) - rust-lang#116432 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 2)) r? `@ghost` `@rustbot` modify labels: rollup
bors
added
S-waiting-on-author
and removed S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.labels
Oct 5, 2023
bors
added
S-waiting-on-bors
and removed S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.labels
Oct 5, 2023
bors
added
S-waiting-on-bors
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.labels
Oct 18, 2023
bors
mentioned this pull request
lqd
mentioned this pull request
joboet
deleted the
global_alloc_tls_unsoundness
branch
bors-ferrocene bot added a commit to ferrocene/ferrocene that referenced this pull request
Oct 31, 2023bors-ferrocene bot added a commit to ferrocene/ferrocene that referenced this pull request
Oct 31, 2023
orlp
mentioned this pull request
orlp
mentioned this pull request
bors added a commit that referenced this pull request
Aug 23, 2025Allow the global allocator to use thread-local storage and std::thread::current() Fixes #115209. Currently the thread-local storage implementation uses the `Global` allocator if it needs to allocate memory in some places. This effectively means the global allocator can not use thread-local variables. This is a shame as an allocator is precisely one of the locations where you'd *really* want to use thread-locals. We also see that this lead to hacks such as #116402, where we detect re-entrance and abort. So I've made the places where I could find allocation happening in the TLS implementation use the `System` allocator instead. I also applied this change to the storage allocated for a `Thread` handle so that it may be used care-free in the global allocator as well, for e.g. registering it to a central place or parking primitives. r? `@joboet`
bors added a commit that referenced this pull request
Oct 21, 2025Allow the global allocator to use thread-local storage and std::thread::current() Fixes #115209. Currently the thread-local storage implementation uses the `Global` allocator if it needs to allocate memory in some places. This effectively means the global allocator can not use thread-local variables. This is a shame as an allocator is precisely one of the locations where you'd *really* want to use thread-locals. We also see that this lead to hacks such as #116402, where we detect re-entrance and abort. So I've made the places where I could find allocation happening in the TLS implementation use the `System` allocator instead. I also applied this change to the storage allocated for a `Thread` handle so that it may be used care-free in the global allocator as well, for e.g. registering it to a central place or parking primitives. r? `@joboet`
bors added a commit that referenced this pull request
Nov 28, 2025Allow the global allocator to use thread-local storage and std::thread::current() Fixes #115209. Currently the thread-local storage implementation uses the `Global` allocator if it needs to allocate memory in some places. This effectively means the global allocator can not use thread-local variables. This is a shame as an allocator is precisely one of the locations where you'd *really* want to use thread-locals. We also see that this lead to hacks such as #116402, where we detect re-entrance and abort. So I've made the places where I could find allocation happening in the TLS implementation use the `System` allocator instead. I also applied this change to the storage allocated for a `Thread` handle so that it may be used care-free in the global allocator as well, for e.g. registering it to a central place or parking primitives. r? `@joboet`
bors added a commit that referenced this pull request
Nov 29, 2025Allow the global allocator to use thread-local storage and std::thread::current() Fixes #115209. Currently the thread-local storage implementation uses the `Global` allocator if it needs to allocate memory in some places. This effectively means the global allocator can not use thread-local variables. This is a shame as an allocator is precisely one of the locations where you'd *really* want to use thread-locals. We also see that this lead to hacks such as #116402, where we detect re-entrance and abort. So I've made the places where I could find allocation happening in the TLS implementation use the `System` allocator instead. I also applied this change to the storage allocated for a `Thread` handle so that it may be used care-free in the global allocator as well, for e.g. registering it to a central place or parking primitives. r? `@joboet`
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request
Nov 30, 2025Allow the global allocator to use thread-local storage and std::thread::current() Fixes rust-lang/rust#115209. Currently the thread-local storage implementation uses the `Global` allocator if it needs to allocate memory in some places. This effectively means the global allocator can not use thread-local variables. This is a shame as an allocator is precisely one of the locations where you'd *really* want to use thread-locals. We also see that this lead to hacks such as rust-lang/rust#116402, where we detect re-entrance and abort. So I've made the places where I could find allocation happening in the TLS implementation use the `System` allocator instead. I also applied this change to the storage allocated for a `Thread` handle so that it may be used care-free in the global allocator as well, for e.g. registering it to a central place or parking primitives. r? `@joboet`
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request
Dec 1, 2025Allow the global allocator to use thread-local storage and std::thread::current() Fixes rust-lang/rust#115209. Currently the thread-local storage implementation uses the `Global` allocator if it needs to allocate memory in some places. This effectively means the global allocator can not use thread-local variables. This is a shame as an allocator is precisely one of the locations where you'd *really* want to use thread-locals. We also see that this lead to hacks such as rust-lang/rust#116402, where we detect re-entrance and abort. So I've made the places where I could find allocation happening in the TLS implementation use the `System` allocator instead. I also applied this change to the storage allocated for a `Thread` handle so that it may be used care-free in the global allocator as well, for e.g. registering it to a central place or parking primitives. r? `@joboet`
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request
Dec 1, 2025Allow the global allocator to use thread-local storage and std::thread::current() Fixes rust-lang/rust#115209. Currently the thread-local storage implementation uses the `Global` allocator if it needs to allocate memory in some places. This effectively means the global allocator can not use thread-local variables. This is a shame as an allocator is precisely one of the locations where you'd *really* want to use thread-locals. We also see that this lead to hacks such as rust-lang/rust#116402, where we detect re-entrance and abort. So I've made the places where I could find allocation happening in the TLS implementation use the `System` allocator instead. I also applied this change to the storage allocated for a `Thread` handle so that it may be used care-free in the global allocator as well, for e.g. registering it to a central place or parking primitives. r? `@joboet`
Kobzol pushed a commit to Kobzol/rustc_codegen_gcc that referenced this pull request
Dec 21, 2025Allow the global allocator to use thread-local storage and std::thread::current() Fixes rust-lang/rust#115209. Currently the thread-local storage implementation uses the `Global` allocator if it needs to allocate memory in some places. This effectively means the global allocator can not use thread-local variables. This is a shame as an allocator is precisely one of the locations where you'd *really* want to use thread-locals. We also see that this lead to hacks such as rust-lang/rust#116402, where we detect re-entrance and abort. So I've made the places where I could find allocation happening in the TLS implementation use the `System` allocator instead. I also applied this change to the storage allocated for a `Thread` handle so that it may be used care-free in the global allocator as well, for e.g. registering it to a central place or parking primitives. r? `@joboet`
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request
Jan 20, 2026…crum Allow the global allocator to use thread-local storage and std::thread::current() Fixes rust-lang#115209. Currently the thread-local storage implementation uses the `Global` allocator if it needs to allocate memory in some places. This effectively means the global allocator can not use thread-local variables. This is a shame as an allocator is precisely one of the locations where you'd *really* want to use thread-locals. We also see that this lead to hacks such as rust-lang#116402, where we detect re-entrance and abort. So I've made the places where I could find allocation happening in the TLS implementation use the `System` allocator instead. I also applied this change to the storage allocated for a `Thread` handle so that it may be used care-free in the global allocator as well, for e.g. registering it to a central place or parking primitives. r? `@joboet`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters