Skip to content

[embedded] Fix an LLVMARCOpts crash by avoiding direct calls to swift_retain/swift_release #69256

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 2 commits into from
Oct 19, 2023

Conversation

kubamracek
Copy link
Contributor

The attached testcase causes a compiler crash (by using -assert-config Debug -Osize compilation flags). Turns out that the ARC optimizer doesn't like the presense of a direct call to swift_retain and swift_release in any Swift code, which is present in embedded runtime (EmbeddedRuntime.swift). Let's simply avoid that.

These are only created by LLVMARCContract !
UNREACHABLE executed at /Users/kuba/swift-github-main/swift/lib/LLVMPasses/LLVMARCOpts.cpp:99!
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
7  swift-frontend           0x0000000104dda3b4 runSwiftARCOpts(llvm::Function&, swift::SwiftRCIdentity&) + 7880
8  swift-frontend           0x0000000104dda480 swift::SwiftARCOptPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) + 48
9  swift-frontend           0x00000001092bf0d4 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) + 308
10 swift-frontend           0x0000000108d5fa20 llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) + 984
11 swift-frontend           0x0000000108d5bec4 llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) + 376

Fixes rdar://117162118.

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek kubamracek added the embedded Embedded Swift label Oct 19, 2023
Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

Can we call this an Ouroboros bug? 😄
lgtm!

@kubamracek
Copy link
Contributor Author

Deal!

git mv test/embedded/arc-crash.swift test/embedded/ouroboros-bug.swift

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek kubamracek merged commit ed105d0 into swiftlang:main Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embedded Embedded Swift
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants