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

[Debug Info] Add missing caching for types with no type sugar #80179

Merged
merged 3 commits into from
Mar 21, 2025

Conversation

adrian-prantl
Copy link
Contributor

This avoids redundant creation and uniquing of types in the case where
we only have a canonical name. Since the uniquing changes the type
graph this introduced the possibility for use-after-free if
IRGenDebugInfoImpl held on to a direct (non-tracking) DIType *.

rdar://146327709

depends on #80170

DBuilder::replaceTemporary() can return a different pointer. In
practice this only happens when temporary and replacement are uniqued,
so that's probably how we got away with this in the past.
when creating the members of a struct, to avoid problems when the type
graph changes due to type nodes being uniqued. It's not clear this can
actually happen, but it helps ruling this out as a failure cause.
This avoids redundant creation and uniquing of types in the case where
we only have a canonical name. Since the uniquing changes the type
graph this introduced the possibility for use-after-free if
IRGenDebugInfoImpl held on to a direct (non-tracking) DIType *.

rdar://146327709
@adrian-prantl
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@augusto2112 augusto2112 left a comment

Choose a reason for hiding this comment

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

I guess writing a test which would result in a use after free before the fix isn't easily done, right?

@adrian-prantl
Copy link
Contributor Author

The reason I didn't bother reducing the type out of the crashing program is that the assertion is an even stronger precondition for the use-after-free and we already trigger it with two tests in the existing test suite.

@adrian-prantl
Copy link
Contributor Author

@swift-ci test macos

@xedin
Copy link
Contributor

xedin commented Mar 21, 2025

@swift-ci please test source compatibility

@adrian-prantl
Copy link
Contributor Author

@xedin

Build log: https://ci.swift.org/job/swift-PR-source-compat-suite-macos/2307/artifact/swift-source-compat-suite/UPASS_Doggie_5.7_BuildSwiftPackage.log

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.

3 participants