Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset rustc's scoped TLS state during unwinding. #47201

Open
eddyb opened this issue Jan 4, 2018 · 2 comments
Open

Reset rustc's scoped TLS state during unwinding. #47201

eddyb opened this issue Jan 4, 2018 · 2 comments
Labels
A-thread-locals Area: Thread local storage (TLS) C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@eddyb
Copy link
Member

eddyb commented Jan 4, 2018

This should only happen in the event of an ICE, but right now, if a Drop implementation (for e.g. a field in Session) would try to access, say, the TLS_TCX, it would use-after-free the global TyCtxt.

@joshlf
Copy link
Contributor

joshlf commented Jan 7, 2018

Isn't this disallowed by the LocalKey requirement that a key's "initializer cannot recursively depend on itself"? To be fair, that wording was only added to the documentation recently.

@eddyb
Copy link
Member Author

eddyb commented Jan 7, 2018

@joshlf We use thread_local to hold a raw pointer in a Cell in order to do scoped TLS, the actual usage of LocalKey itself is trivial, it's what we do with the pointer that matters.

@pietroalbini pietroalbini added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 6, 2018
@jonas-schievink jonas-schievink added the A-thread-locals Area: Thread local storage (TLS) label Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-thread-locals Area: Thread local storage (TLS) C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants