Skip to content

[cxx-interop] Mark clang-related requests as un-cached. #64755

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

Merged

Conversation

zoecarver
Copy link
Contributor

Pointers from clang appear to be unstable in some capacity. We would find the result of unrelated methods that were cached using this request. My theory is that clang loads one module, then frees its AST when it's done, or maybe just re-allocates the AST at some point. In any case, we cannot cache requests on clang pointers.

This should fix the flakeyness issue that we've been seeing for a while.

Pointers from clang appear to be unstable in some capacity. My theory is that clang loads one module, then frees its AST when it's done, or maybe just re-allocates the AST at some point. In any case, we cannot cache requests on clang pointers.

This should fix the flakeyness issue that we've been seeing for a while.
@zoecarver zoecarver force-pushed the mark-is-safe-use-req-as-uncached branch from 3279b4d to 22dd716 Compare March 30, 2023 01:17
@zoecarver
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯

@zoecarver zoecarver merged commit b4e2969 into swiftlang:main Mar 30, 2023
@zoecarver
Copy link
Contributor Author

From the 🍒 pick:

To follow up on this: when a user imports some clang modules, clang goes off to load those modules on separate threads. Each of these modules gets its own ASTContext which is later copied into the primary ASTContext. When loading a module and writing out a PCM file, Clang invokes a customization point, where Swift builds a lookup table from the clang AST. This lookup table imports a bunch of Clang names. During this import of clang names, the ASTContext and all Decl pointers are not stable (because they are part of the non-primary ASTContext), so any caching on these pointers will lead to very odd behavior.

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.

2 participants