Skip to content

[6.2] [Runtime] Properly deallocate extended storage for conformance cache entries #80887

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

Conversation

DougGregor
Copy link
Member

  • Explanation: When the conformance cache has to allocate an "extended" cache entry, which includes information about global actor isolation for the conformance, that memory was not being freed when the conformance cache is cleared, for example when a new shared library is loaded via dlopen or similar. Keep track of these allocations in a list, and move them over to the concurrent free list in the conformance cache when clearing the cache, so they will eventually be deallocated.
  • Scope: Limited to the conformance cache in the runtime, and only has an effect when using isolated conformances.
  • Issues: Noticed as part of rdar://149326058.
  • Original PRs: [Runtime] Properly deallocate extended storage for conformance cache entries #80865
  • Risk: Relatively low. It's some lock-free freelist handling in the runtime on top of an existing freelist mechanism, but in a very narrow place and fairly straightforward.
  • Testing: CI.
  • Reviewers: @al45tair

… free list

This memory is part of the conformance cache concurrent hash map, so
when we clear the conformance cache, record each of the allocated
pointers within the concurrent map's free list. This way, it'll be
freed with the rest of the concurrent map when it's safe to do so.

(cherry picked from commit 885f829)
@DougGregor DougGregor requested a review from a team as a code owner April 17, 2025 16:16
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor DougGregor merged commit c363658 into swiftlang:release/6.2 Apr 18, 2025
5 checks passed
@DougGregor DougGregor deleted the conformance-cache-extended-entry-deleak-6.2 branch April 18, 2025 02: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.

2 participants