Skip to content

Modify LocalLifetime destructor to clear local cache#2670

Open
hmenke wants to merge 1 commit into
facebook:mainfrom
hmenke:LocalLifetime
Open

Modify LocalLifetime destructor to clear local cache#2670
hmenke wants to merge 1 commit into
facebook:mainfrom
hmenke:LocalLifetime

Conversation

@hmenke

@hmenke hmenke commented Jul 10, 2026

Copy link
Copy Markdown

destroy(getWrapper()) re-enters ThreadLocalPtr::get() while TLS destructors are already running. This crashes sometimes, see e.g. #2002. Instead avoid re-entering ThreadLocal in the TLS destructor and only clears the local fast-path cache getLocalCache().object = nullptr, which is sufficient to prevent stale reuse.

fixes #1252 , fixes #2002

`destroy(getWrapper())` re-enters `ThreadLocalPtr::get()` while TLS destructors
are already running. This crashes sometimes, see e.g. facebook#2002. Instead avoid
re-entering `ThreadLocal` in the TLS destructor and only clears the local
fast-path cache `getLocalCache().object = nullptr`, which is sufficient to
prevent stale reuse.

Signed-off-by: Henri Menke <henri@henrimenke.de>
@meta-cla

meta-cla Bot commented Jul 10, 2026

Copy link
Copy Markdown

Hi @hmenke!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@hmenke

hmenke commented Jul 10, 2026

Copy link
Copy Markdown
Author

I will never sign a CLA! This patch is offered under the Developer Certificate of Origin. Do with that what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coredump when another thread destroy Coredump when running global_executor_test

1 participant