std: don't clean up the main thread's altstack - #161037
Open
joboet wants to merge 1 commit into
Open
Conversation
Collaborator
|
r? @clarfonthey rustbot has assigned @clarfonthey. Use Why was this reviewer chosen?The reviewer was selected based on:
|
clarfonthey
reviewed
Aug 13, 2026
Comment on lines
+146
to
+151
| // Store a pointer to the allocation for the main thread's altstack so that | ||
| // tools like valgrind don't complain about a leaked unreachable allocation. | ||
| // | ||
| // If the main thread exits, the process will terminate so there's no use in | ||
| // freeing resources. It also means that the altstack is still installed | ||
| // while TLS destructors are run on the main thread (c.f. #111272). |
Contributor
There was a problem hiding this comment.
Minor nit: since we can generate private docs these should probably just be doc comments.
Contributor
|
Agree with the discussion that this is probably a lot more headaches than it's worth, although I think it's probably worth verifying that we've fixed the issues with flushing output on exit. It looks like that code has been since relocated, but I'm not 100% sure just looking at it. |
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.
Fixes #161018
#28069 added a call to what is now
rt::cleanuptoprocess::exit.rt::cleanupin turn calls the UNIXstack_overflow::cleanup, which frees the main thread's signal stack and uninstalls the current thread's signal handler in the assumption that the current thread is the main one – even thoughprocess::exitcan be called from any thread.This PR removes the main thread cleanup logic altogether, since, as the FIXME in
stack_overflow::cleanuppoints out, it causes more issues than it is worth. This also means that stack overflows in TLS destructors will be caught on the main thread, partly addressing #111272.