Repository navigation
Conversation
Collaborator
|
r? @jhpratt rustbot has assigned @jhpratt. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
joboet
force-pushed
the
eager_tls_dtors
branch
from
October 25, 2026 15:52
c68840f to
fe7ad5c
Compare
Member
Author
|
@bors try jobs=test-aarch64-apple-,test-x86_64-msvc- |
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
Oct 25, 2026
std: eargerly run TLS destructors to catch stack overflows try-job: test-aarch64-apple-* try-job: test-x86_64-msvc-*
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Contributor
|
💔 Test for 0f4573b failed: CI. Failed jobs:
|
Member
Author
|
I don't get why that test is failing – it's completely unrelated, and doesn't even fail when I run it locally. Is that known to be spurious? Anyway, I'll mark this as ready for review. |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This addresses #111272 on UNIX platforms with native TLS by eagerly running the destructors of TLS variables inside the thread main function while the stack overflow detection logic is still active. I've previously tried this strategy in #109858, but that failed on the Apple platforms because I removed the
_tlv_atexitimplementation ofguard::enablein favour of the pthread-TLS-based implementation which doesn't work on Apple (see the updated documentation in the corresponding file for why that is).This obviously requires us to always manage the list of destructors manually, even on platforms like Linux that allow registering a per-object destructor. While that makes it slightly harder to support the case where a library referencing an instance of
stddefined in a separate DSO is unloaded, we currently don't support that anyway –__cxa_thread_atexit_implprevents the unloading of the DSO referenced by thedso_symbolargument, but we always reference thedso_handleliving alongsidestdinstead of the one of the DSO where the variable is defined.I've also added a drive-by commit updating the documentation of the Apple thread guard with some interesting caveats I've recently come across.