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

async func that is conditionally recursive crashes nightly compiler #68708

Open
dnadoba opened this issue Sep 22, 2023 · 1 comment
Open

async func that is conditionally recursive crashes nightly compiler #68708

dnadoba opened this issue Sep 22, 2023 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@dnadoba
Copy link
Contributor

dnadoba commented Sep 22, 2023

The following program crashes 5.9 nightly and main nightly:

func foo() async {
    await bar()
}

func bar() async {
    if Bool.random() {
        await foo()
    }
}

crash backtrace:

root@1894360cba41:/src# swift build
Building for debugging...
error: compile command failed due to signal 11 (use -v to see invocation)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /usr/bin/swift-frontend -frontend -c -primary-file /src/Sources/PlaygroundTarget/Target.swift -emit-dependencies-path /src/.build/aarch64-unknown-linux-gnu/debug/PlaygroundTarget.build/Target.d -emit-reference-dependencies-path /src/.build/aarch64-unknown-linux-gnu/debug/PlaygroundTarget.build/Target.swiftdeps -target aarch64-unknown-linux-gnu -Xllvm -aarch64-use-tbi -disable-objc-interop -I /src/.build/aarch64-unknown-linux-gnu/debug -color-diagnostics -enable-testing -g -module-cache-path /src/.build/aarch64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -fPIC -Xcc -g -module-name PlaygroundTarget -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins -parse-as-library -o /src/.build/aarch64-unknown-linux-gnu/debug/PlaygroundTarget.build/Target.swift.o -index-store-path /src/.build/aarch64-unknown-linux-gnu/debug/index/store -index-system-modules
1.	Swift version 5.11-dev (LLVM 5601e23279f85d8, Swift a119aafe36797b8)
2.	Compiling with the current language version
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/usr/bin/swift-frontend(+0x6cce3f8)[0xaaaab56de3f8]
/usr/bin/swift-frontend(+0x6ccc3e8)[0xaaaab56dc3e8]
/usr/bin/swift-frontend(+0x6cce814)[0xaaaab56de814]
linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0xffffb808378c]
/usr/bin/swift-frontend(+0x635e804)[0xaaaab4d6e804]
/usr/bin/swift-frontend(+0x627b484)[0xaaaab4c8b484]
/usr/bin/swift-frontend(+0x6277328)[0xaaaab4c87328]
/usr/bin/swift-frontend(+0x435d254)[0xaaaab2d6d254]
/usr/bin/swift-frontend(+0x626fc60)[0xaaaab4c7fc60]
/usr/bin/swift-frontend(+0x6271438)[0xaaaab4c81438]
/usr/bin/swift-frontend(+0x69868ac)[0xaaaab53968ac]
/usr/bin/swift-frontend(+0x69868ac)[0xaaaab53968ac]
/usr/bin/swift-frontend(+0x123ccc4)[0xaaaaafc4ccc4]
/usr/bin/swift-frontend(+0x123e65c)[0xaaaaafc4e65c]
/usr/bin/swift-frontend(+0xee1cb0)[0xaaaaaf8f1cb0]
/usr/bin/swift-frontend(+0xedd81c)[0xaaaaaf8ed81c]
/usr/bin/swift-frontend(+0xedc7cc)[0xaaaaaf8ec7cc]
/usr/bin/swift-frontend(+0xeee6d4)[0xaaaaaf8fe6d4]
/usr/bin/swift-frontend(+0xedf71c)[0xaaaaaf8ef71c]
/usr/bin/swift-frontend(+0xede22c)[0xaaaaaf8ee22c]
/usr/bin/swift-frontend(+0xcf33c8)[0xaaaaaf7033c8]
/lib/aarch64-linux-gnu/libc.so.6(+0x273fc)[0xffffb65873fc]
/lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98)[0xffffb65874cc]
/usr/bin/swift-frontend(+0xcf25b0)[0xaaaaaf7025b0]

*** Program crashed: Bad pointer dereference at 0x0000000000000000 ***

Thread 0 "swift-frontend" crashed:

 0      0x0000aaaab4d6e804 llvm::LazyCallGraph::RefSCC::removeOutgoingEdge(llvm::LazyCallGraph::Node&, llvm::LazyCallGraph::Node&) + 8 in swift-frontend
 1 [ra] 0x0000aaaab4c8b484 bool __gnu_cxx::__ops::_Iter_pred<updateCGAndAnalysisManagerForPass(llvm::LazyCallGraph&, llvm::LazyCallGraph::SCC&, llvm::LazyCallGraph::Node&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::CGSCCUpdateResult&, llvm::AnalysisManager<llvm::Function>&, bool)::$_3>::operator()<llvm::LazyCallGraph::Node**>(llvm::LazyCallGraph::Node**) + 563 in swift-frontend
 2 [ra] 0x0000aaaab4c87328 updateCGAndAnalysisManagerForPass(llvm::LazyCallGraph&, llvm::LazyCallGraph::SCC&, llvm::LazyCallGraph::Node&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::CGSCCUpdateResult&, llvm::AnalysisManager<llvm::Function>&, bool) + 3695 in swift-frontend
 3 [ra] 0x0000aaaab2d6d254 llvm::CoroSplitPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) + 1347 in swift-frontend
 4 [ra] 0x0000aaaab4c7fc60 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&) + 371 in swift-frontend
 5 [ra] 0x0000aaaab4c81438 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 3547 in swift-frontend
 6 [ra] 0x0000aaaab53968ac llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 303 in swift-frontend
 7 [ra] 0x0000aaaab53968ac llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 303 in swift-frontend
 8 [ra] 0x0000aaaaafc4ccc4 swift::performLLVMOptimizations(swift::IRGenOptions const&, llvm::Module*, llvm::TargetMachine*, llvm::raw_pwrite_stream*) + 4519 in swift-frontend
 9 [ra] 0x0000aaaaafc4e65c swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, llvm::StringRef, llvm::vfs::OutputBackend&, swift::UnifiedStatsReporter*) + 1107 in swift-frontend
10 [ra] 0x0000aaaaaf8f1cb0 generateCode(swift::CompilerInstance&, llvm::StringRef, llvm::Module*, llvm::GlobalVariable*) + 251 in swift-frontend
11 [ra] 0x0000aaaaaf8ed81c performCompileStepsPostSILGen(swift::CompilerInstance&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1527 in swift-frontend
12 [ra] 0x0000aaaaaf8ec7cc swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 383 in swift-frontend
13 [ra] 0x0000aaaaaf8fe6d4 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 171 in swift-frontend
14 [ra] 0x0000aaaaaf8ef71c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1487 in swift-frontend
15 [ra] 0x0000aaaaaf8ee22c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2335 in swift-frontend
16 [ra] 0x0000aaaaaf7033c8 swift::mainEntry(int, char const**) + 2735 in swift-frontend
17 [ra] 0x0000ffffb65873fc <unknown> in libc.so.6
18 [ra] 0x0000ffffb65874cc <unknown> in libc.so.6


Registers:

 x0 0x0000000000000000  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ················
 x1 0x0000aaaacd61f310  a8 38 41 cd aa aa 00 00 f8 b6 7b cd aa aa 00 00  ¨8Aͪª··ø¶{ͪª··
 x2 0x0000aaaacd61f3f0  a8 38 41 cd aa aa 00 00 98 cb 7b cd aa aa 00 00  ¨8Aͪª···Ë{ͪª··
 x3 0x0000000000000008  a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8  ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
 x4 0x0000fffff4d1c060  a8 38 41 cd aa aa 00 00 10 f3 61 cd aa aa 00 00  ¨8Aͪª···óaͪª··
 x5 0x0000aaaacd7273c0  20 f6 61 cd aa aa 00 00 70 f7 61 cd aa aa 00 00   öaͪª··p÷aͪª··
 x6 0x0000aaaacd61f3f0  a8 38 41 cd aa aa 00 00 98 cb 7b cd aa aa 00 00  ¨8Aͪª···Ë{ͪª··
 x7 0x0000aaaacd61f2a0  a8 38 41 cd aa aa 00 00 b8 14 7b cd aa aa 00 00  ¨8Aͪª··¸·{ͪª··
 x8 0x0000fffff4d1c3f0  00 00 00 00 00 00 00 00 b0 4f 7b cd aa aa 00 00  ········°O{ͪª··
 x9 0x0000fffff4d1c3f0  00 00 00 00 00 00 00 00 b0 4f 7b cd aa aa 00 00  ········°O{ͪª··
x10 0x000000000000003f  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ················
x11 0x0000aaaacd61f3f0  a8 38 41 cd aa aa 00 00 98 cb 7b cd aa aa 00 00  ¨8Aͪª···Ë{ͪª··
x12 0x000000000000003f  a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8  ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
x13 0x0000aaaacd61f770  a8 38 41 cd aa aa 00 00 c8 56 7c cd aa aa 00 00  ¨8Aͪª··ÈV|ͪª··
x14 0x0000000000000042  a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8  ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
x15 0x0000000000000000  a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8  ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
x16 0x0000aaaab6c80060  40 7b 5f b6 ff ff 00 00 d4 db 5e b6 ff ff 00 00  @{_¶ÿÿ··ÔÛ^¶ÿÿ··
x17 0x0000ffffb65f7b40  1f 20 03 d5 24 00 02 8b 05 00 02 8b 5f 00 02 f1  · ·Õ$·······_··ñ
x18 0x0000000000000001  1f 1f 1f 1f 1f 1f 1f 1f 1f 1f 1f 1f 1f 1f 1f 1f  ················
x19 0x0000aaaacd61f3f0  a8 38 41 cd aa aa 00 00 98 cb 7b cd aa aa 00 00  ¨8Aͪª···Ë{ͪª··
x20 0x0000fffff4d1bfa8  a8 38 41 cd aa aa 00 00 f0 c3 d1 f4 ff ff 00 00  ¨8Aͪª··ðÃÑôÿÿ··
x21 0x0000aaaacd7273d0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ················
x22 0x0000000000000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ················
x23 0x0000aaaacd6e4108  a8 38 41 cd aa aa 00 00 20 41 6e cd aa aa 00 00  ¨8Aͪª·· Anͪª··
x24 0x0000000000000000  a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8 a8  ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
x25 0x0000fffff4d1e320  04 00 00 00 00 00 00 00 10 1f 7a cd aa aa 00 00  ··········zͪª··
x26 0x0000aaaacd4138a8  e0 f7 61 cd aa aa 00 00 a0 02 62 cd aa aa 00 00  à÷aͪª·· ·bͪª··
x27 0x0000aaaacd61f310  a8 38 41 cd aa aa 00 00 f8 b6 7b cd aa aa 00 00  ¨8Aͪª··ø¶{ͪª··
x28 0x0000aaaacd7bb740  1c 52 72 cd aa aa 00 00 88 b9 7b cd aa aa 00 00  ·Rrͪª···¹{ͪª··
 fp 0x0000fffff4d1bed0  e0 be d1 f4 ff ff 00 00 84 b4 c8 b4 aa aa 00 00  à¾Ñôÿÿ···´È´ªª··
 lr 0x0000aaaab4c8b484  ff 02 18 eb e0 07 9f 1a f4 4f 43 a9 f6 57 42 a9  ÿ··ëà···ôOC©öWB©
 sp 0x0000fffff4d1bed0  e0 be d1 f4 ff ff 00 00 84 b4 c8 b4 aa aa 00 00  à¾Ñôÿÿ···´È´ªª··
 pc 0x0000aaaab4d6e804  08 00 40 f9 09 49 41 b9 c9 06 00 34 2a 00 74 b2  ··@ù·IA¹É··4*·t²


Images (22 omitted):

0x0000aaaaaea10000–0x0000aaaab6417a68 <no build ID>                            swift-frontend /usr/bin/swift-frontend
0x0000ffffb6560000–0x0000ffffb66e8214 8bc05193761d5da11e20f1b678fb8f80126b227f libc.so.6      /usr/lib/aarch64-linux-gnu/libc.so.6

Reproduce:
Either compile the code snipped above or the attached Swift Package with swift build
PlaygroundExecutbale.zip
Note: only tested in docker on Linux (swiftlang/swift:nightly-main-jammy)

Version: Swift version 5.11-dev (LLVM 5601e23279f85d8, Swift a119aaf)
also tested with: Swift version 5.9.2-dev (LLVM b3da2fc5510a8c2, Swift 49fe7f7)

@dnadoba dnadoba added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Sep 22, 2023
@dnadoba
Copy link
Contributor Author

dnadoba commented Sep 22, 2023

rdar://115905828

aschwaighofer added a commit to aschwaighofer/swift that referenced this issue Feb 6, 2024
aschwaighofer added a commit to aschwaighofer/llvm-project that referenced this issue Feb 7, 2024
The call to the inlining utility does not update the call graph.
Leading to assertion failures when calling the utility to update the
call graph.

Instead rely on an inline pass to run after coro splitting and use
alwaysinline annotations.

github.com/swiftlang/swift/issues/68708
rdar://115905828
aschwaighofer added a commit to aschwaighofer/llvm-project that referenced this issue Feb 7, 2024
The call to the inlining utility does not update the call graph.
Leading to assertion failures when calling the utility to update the
call graph.

Instead rely on an inline pass to run after coro splitting and use
alwaysinline annotations.

github.com/swiftlang/swift/issues/68708
aschwaighofer added a commit to llvm/llvm-project that referenced this issue Feb 7, 2024
The call to the inlining utility does not update the call graph. Leading
to assertion failures when calling the call graph utility to update the
call graph.

Instead rely on an inline pass to run after coro splitting and use
alwaysinline annotations.

github.com/swiftlang/swift/issues/68708
aschwaighofer added a commit to aschwaighofer/llvm-project that referenced this issue Apr 9, 2024
…ttailcc thunks

The call to the inlining utility does not update the call graph. Leading
to assertion failures when calling the call graph utility to update the
call graph.

Instead rely on an inline pass to run after coro splitting and use
alwaysinline annotations.

We can only do this if the calling convention used for the thunks is
`swifttailcc` otherwise we would break clients that use other
calling conventions.

Previous instance of this PR was llvm#80904.

github.com/swiftlang/swift/issues/68708
aschwaighofer added a commit to aschwaighofer/llvm-project that referenced this issue Apr 16, 2024
…ttailcc thunks

The call to the inlining utility does not update the call graph. Leading
to assertion failures when calling the call graph utility to update the
call graph.

Instead rely on an inline pass to run after coro splitting and use
alwaysinline annotations.

We can only do this if the calling convention used for the thunks is
`swifttailcc` otherwise we would break clients that use other
calling conventions.

Previous instance of this PR was llvm#80904.

github.com/swiftlang/swift/issues/68708
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. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant