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

[SR-12208] SILOptimizer crash #54634

Closed
swift-ci opened this issue Feb 15, 2020 · 7 comments
Closed

[SR-12208] SILOptimizer crash #54634

swift-ci opened this issue Feb 15, 2020 · 7 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-12208
Radar rdar://problem/59496025
Original Reporter shoffmann (JIRA User)
Type Bug
Status Closed
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, OptimizedOnly
Assignee None
Priority Medium

md5: cadb596f45c3bc703433d49e41d8e31a

Issue Description:

Debug configuration builds just fine while release fails with:

swift build -c release

swift: /home/buildnode/jenkins/workspace/oss-swift-5.1-package-linux-ubuntu-18_04/swift/lib/SILOptimizer/Analysis/EscapeAnalysis.cpp:1763: bool swift::EscapeAnalysis::mergeCalleeGraph(swift::SILInstruction *, swift::EscapeAnalysis::ConnectionGraph *, swift::EscapeAnalysis::ConnectionGraph *): Assertion numCalleeArgs >= numCallerArgs' failed.swift: /home/buildnode/jenkins/workspace/oss-swift-5.1-package-linux-ubuntu-18_04/swift/lib/SILOptimizer/Analysis/EscapeAnalysis.cpp:1763: bool swift::EscapeAnalysis::mergeCalleeGraph(swift::SILInstruction *, swift::EscapeAnalysis::ConnectionGraph *, swift::EscapeAnalysis::ConnectionGraph *): Assertion numCalleeArgs >= numCallerArgs' failed.Stack dump:0. Program arguments: ... -frontend -c ... -supplementary-output-file-map /tmp/supplementaryOutputs-df1651 -target x86_64-unknown-linux -disable-objc-interop -sdk / -I /... -swift-version 5 -O -D SWIFT_PACKAGE -color-diagnostics -Xcc -fmodule-map-file=... -parse-as-library -module-name Core -num-threads 4 -o ...

While running pass #​21558 SILFunctionTransform "EarlyRedundantLoadElimination" on SILFunction "@$s4Core7AnyNodeC016processAndNotifyB033_07275164D393B8F91FD801749F4C4154LLyyypF". for 'processAndNotifyAny(_:)' (at .../Node.swift:68:11)/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x451a3b4]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x451800e]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x451a7c8]/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7f2e60acf890]/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f2e5ef32e97]/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f2e5ef34801]/lib/x86_64-linux-gnu/libc.so.6(+0x3039a)[0x7f2e5ef2439a]/lib/x86_64-linux-gnu/libc.so.6(+0x30412)[0x7f2e5ef24412]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0xb6e7da]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0xb6ddf6]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0xb6eb69]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0xb89bd0]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0xb87c48]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0xb877b6]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x9fad16]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x9f1cab]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x935a8d]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x936822]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x93793f]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x550048]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x93fb6c]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x749052]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x4d4ad4]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x4d0cde]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x473b16]/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f2e5ef15b97]/home/eth/swift/swift-5.1.1-RELEASE-ubuntu18.04/usr/bin/swift[0x47377a]

The code in question:

fileprivate func processAny(_ : Any) throws -> Any? {
fatalError("AnyNode.processAny() has not been implemented")
}

/// Notfies any outNodes that we are done and passes our result
fileprivate func notifyAny(_ result: Any) {
for node in outNodes {
node.queue.async {
node.processAndNotifyAny(result)
}
}
}

private func processAndNotifyAny(_ input: Any) {
do {
let result = try processAny(input)
if result != nil {
notifyAny(result!)
}
} catch {
logger.error("Errror during processing of node (name): (error)")
}
}

@swift-ci
Copy link
Collaborator Author

Comment by Sebastian Hoffmann (JIRA)

Also crashes with 5.1.4

@theblixguy
Copy link
Collaborator

cc @eeckstein

@beccadax
Copy link
Contributor

@swift-ci create

@atrick
Copy link
Member

atrick commented Feb 25, 2020

shoffmann (JIRA User)I haven't been able to reproduce a crash yet just by filling in placeholders where the code is incomplete. It's not surprising because what happens inside the optimizer is very sensitive so small changes in the surrounding code. Can you provide a test case that builds and reproduces the problem, or at least as much context as possible?

@swift-ci
Copy link
Collaborator Author

swift-ci commented Mar 1, 2020

Comment by Sebastian Hoffmann (JIRA)

@atrick Yes indeed. I did some small refactoring to the code in question and now the crash is gone. I will try to come up with a minimal reproduceable example based on the old revision within in the next days. Unfortunately I can't disclose the whole codebase. Should I be unable to do so: Are there any intermediary files which would be helpful? I know that swiftc comes with alot of flags to provide output of various compilation stages.

@atrick
Copy link
Member

atrick commented Mar 1, 2020

These are always good flags to use for compiler asserts:

-Xllvm -sil-print-on-error -Xfrontend -sil-verify-all

Something got inlined into `processAndNotifyAny` and caused a problem, but I'm not sure what.

To reduce it, I would try to remove as many of the calls as possible from `processAndNotifyAny`, without changing anything else. Then you know what got inlined. From there, I would replace any types that are still referenced with dummy proxies. It takes time to reduce problems, but it's really helpful to have that test case. The compiler code around that assert looks very sketchy to me, but I don't know how to contrive a test case that would break it.

@atrick
Copy link
Member

atrick commented May 11, 2021

It's likely that this crash occurred while the EscapeAnalysis code was still in flux. It's been a year since anyone was able to reproduce it. If it happens again though please reopen.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation
Projects
None yet
Development

No branches or pull requests

5 participants