Skip to content

[SIL] Fix use-after-free in SILFunction::print. #29949

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 21, 2020

Conversation

dan-zheng
Copy link
Contributor

@dan-zheng dan-zheng commented Feb 20, 2020

Fix use-after-free in helper function printSILFunctionNameAndType.
The address of a DenseMap local variable was used after the function returned.

Resolves SR-12239.

Fix use-after-free in helper function `printSILFunctionNameAndType`.
The address of a `DenseMap` local variable is used after the function returns.

Resolves SR-12239.
@dan-zheng
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@varungandhi-apple varungandhi-apple left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM. Could you briefly describe your debugging process/how you got the reduced test case? Did you use ASan [or run into any troubles using ASan]?

@dan-zheng
Copy link
Contributor Author

dan-zheng commented Feb 20, 2020

Could you briefly describe your debugging process/how you got the reduced test case? Did you use ASan [or run into any troubles using ASan]?

I followed reproducer instructions at SR-12239 and found that the crash occurred during stdlib compilation for a specific function: _withContiguousStorage in stdlib/public/core/Diffing.swift. Diffing.swift was a single file reproducer. I manually minimized it to three lines.

I just used print debugging, nothing fancy - the buggy code was familiar to me since I wrote it. Sorry for introducing the bug!

I actually haven't used ASan for debugging Swift. I'm not sure how exactly to apply it here.

@dan-zheng
Copy link
Contributor Author

I'm not sure how exactly to address #29949 (comment): making the added test an ASAN test.

I'll merge this PR now to unblock progress, since I ran into SR-12239 independently. Happy to address feedback later.

@dan-zheng dan-zheng merged commit 9600b97 into swiftlang:master Feb 21, 2020
@dan-zheng dan-zheng deleted the SR-12239 branch February 21, 2020 01:53
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