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

review: fix: Use thread-local caching for actual class lookup #4671

Merged
merged 4 commits into from
Apr 11, 2022

Conversation

slarse
Copy link
Collaborator

@slarse slarse commented Apr 10, 2022

Fix #4668

This is a quick-fix to avoid the cross-thread race condition when invalidating the cache and then doing a lookup in it. This is a problem as the current lock is per-instance but the cache is static, so in theory a thread A could check the cache integrity and state that it's fine, then there's a context switch to thread B which does the same thing and invalidates the cache and inserts something into the cache, and then we're back to thread B which does a lookup on a "bad cache" (according to thread A's view of the world).

By using thread-local storage, this situation cannot occur.

@slarse slarse changed the title fix: Use thread-local caching for actual class lookup review: fix: Use thread-local caching for actual class lookup Apr 10, 2022
@MartinWitt
Copy link
Collaborator

LGTM as a short-term fix.

@MartinWitt MartinWitt merged commit 97c9d07 into INRIA:master Apr 11, 2022
@MartinWitt
Copy link
Collaborator

thanks, @slarse

@slarse slarse deleted the issue/4668-thread-local-caching branch April 11, 2022 11:07
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.

A question regarding how CtTypeReferenceImpl retrieves its type.
2 participants