Skip to content

[ClangImporter] Fix stack-use-after-scope in createClangInvocation #63881

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
merged 1 commit into from
Feb 24, 2023

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Feb 24, 2023

ClangDiagnosticConsumer was initialized on the stack in a scope of 'if' branch, and was passed to the DiagnosticEngine as a pointer. Then the diagnostic engine was used outside the scope.

Instead, allocate the consumer in the heap, and pass to the engine with ShouldOwnClient true. So the engine takes the ownership.

Speculative fix for rdar://105801504

ClangDiagnosticConsumer was initialized on the stack in a scope of 'if'
branch, and was passed to the DiagnosticEngine as a pointer. Then the
diagnostic engine was used outside the scope.

Instead, allocate the consumer in the heap, and pass to the engine with
`ShouldOwnClient` true. So the engine takes the ownership.

Speculative fix for rdar://105801504
@rintaro rintaro marked this pull request as ready for review February 24, 2023 05:38
@rintaro
Copy link
Member Author

rintaro commented Feb 24, 2023

@swift-ci Please smoke test

@rintaro rintaro merged commit 6a5c0d0 into swiftlang:main Feb 24, 2023
bnbarham added a commit to bnbarham/swift that referenced this pull request Mar 28, 2023
This was fixed by swiftlang#63881, ie. a stack
use after scope.

Resolves rdar://100508951.
etcwilde pushed a commit to etcwilde/swift that referenced this pull request Apr 19, 2023
This was fixed by swiftlang#63881, ie. a stack
use after scope.

Resolves rdar://100508951.
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