Skip to content

Fix for a crash due to performLocalReleaseMotion and performLocalRetainMotion #38150

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
Jun 30, 2021

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Jun 29, 2021

In low level LLVMARCOptimizer, during canonicalization we don't rauw the result of RT_Retain and RT_UnknownObjectRetain with its arg similarly to RT_ObjCRetain and RT_BridgeRetain.
And during performLocalReleaseMotion, we assert that we have canonicalized RT_Retain/RT_UnknownObjectRetain.
In a release compiler, if we optimize such an RT_Retain/RT_UnknownObjectRetain with a RT_Release/RT_UnknownObjectRelease, then this can result in a compiler crash

Similarly not rauw'ing, can cause a crash due to performLocalRetainMotion.

Note: This crash may only happen when LLVM fails to optimize these retain calls which are marked with returned attribute.

Fixes rdar://79238115

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta meg-gupta force-pushed the fixlowlevelarcassert branch from 89dd896 to cbb2ad1 Compare June 29, 2021 17:10
@meg-gupta meg-gupta changed the title Fix for a crash due to performLocalReleaseMotion Fix for a crash due to performLocalReleaseMotion and performLocalRetainMotion Jun 29, 2021
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta meg-gupta requested a review from eeckstein June 29, 2021 17:55
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - cbb2ad1c2384c7ae555ab093efb20848fe9f608e

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - cbb2ad1c2384c7ae555ab093efb20848fe9f608e

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Can you explain why we don't need RAUW for the RT_UnknownObjectRetain case?

…inMotion

In low level LLVMARCOptimizer, during canonicalization we don't rauw the result of RT_Retain with its arg similarly to RT_ObjCRetain and RT_BridgeRetain.
And during performLocalReleaseMotion, we assert that we have canonicalized RT_Retain.
In a release compiler, if we optimize such an RT_Retain with a RT_Release, then this can result in a compiler crash

Similarly not rauw'ing, can cause a crash due to performLocalRetainMotion

Fixes rdar://79238115
@meg-gupta meg-gupta force-pushed the fixlowlevelarcassert branch from cbb2ad1 to 386cc23 Compare June 29, 2021 21:22
@meg-gupta
Copy link
Contributor Author

@atrick The same issue can also happen with RT_UnknownObjectRetain. Fixed it. Thanks

@meg-gupta meg-gupta requested a review from atrick June 29, 2021 21:29
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 386cc23

@meg-gupta
Copy link
Contributor Author

@swift-ci test Linux Platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 386cc23

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Excellent. Thanks!

@meg-gupta
Copy link
Contributor Author

Trying again... @swift-ci test Linux Platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 386cc23

@meg-gupta
Copy link
Contributor Author

@swift-ci test Linux Platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 386cc23

@meg-gupta
Copy link
Contributor Author

Another flaky error. Trying again... @swift-ci smoke test Linux Platform

@meg-gupta
Copy link
Contributor Author

@swift-ci clean smoke test Linux Platform

@meg-gupta meg-gupta merged commit 87cde88 into swiftlang:main Jun 30, 2021
meg-gupta added a commit to meg-gupta/swift that referenced this pull request Jul 1, 2021
…inMotion (swiftlang#38150)

In low level LLVMARCOptimizer, during canonicalization we don't rauw the result of RT_Retain with its arg similarly to RT_ObjCRetain and RT_BridgeRetain.
And during performLocalReleaseMotion, we assert that we have canonicalized RT_Retain.
In a release compiler, if we optimize such an RT_Retain with a RT_Release, then this can result in a compiler crash

Similarly not rauw'ing, can cause a crash due to performLocalRetainMotion

Fixes rdar://79238115
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