Skip to content

Async function never returns in Swift 5.7 in release + static linking (Linux) #59961

@PopFlamingo

Description

@PopFlamingo

Describe the bug
I found a specific project setup where a simple call to a mostly empty async function never returns (note that this doesn't happen in simpler setups without some dependencies, see the linked repo for a reproducible issue).
Also, with some additional dependencies, even if not imported but just listed as dependencies in Package.swift, it can change the behavior and cause a crash with a segfault for instance.

Here, swift run -c release -Xswiftc -static-executable never goes beyond printing "During foo()"

func foo() async {
    print("During foo()")
}

@main
struct App {
    static func main() async throws {
        print("Before calling foo()")
        let bar = await foo()
        print("After calling foo()")
    }
}

Steps To Reproduce
Steps to reproduce the behavior:

  1. Clone https://github.com/PopFlamingo/fluffy-disco.git
  2. Run it with swift run -c release -Xswiftc -static-executable (I can reproduce from the swiftlang/swift:nightly-5.7-focal Docker image which currently has the following toolchain Swift version 5.7-dev (LLVM c94b55955148b74, Swift 13b3ac91a618617))

Note that the linked repo has a .devcontainer included for easier reproduction in VSCode and others.

Expected behavior
Program should print and exit but does not and stops in the foo() call.

Environment (please fill out the following information)

swift --version
Swift version 5.7-dev (LLVM c94b55955148b74, Swift 13b3ac91a618617)
Target: x86_64-unknown-linux-gnu

cc @ktoso

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuressswgIssues related to Serverside Swift Work Group projects

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions