Skip to content

[SR-15683] Program crashes when adding many tasks to a TaskGroup on Windows #57962

@MarSe32m

Description

@MarSe32m
Previous ID SR-15683
Radar None
Original Reporter @MarSe32m
Type Bug
Environment

Windows, snapshot: swift-DEVELOPMENT-SNAPSHOT-2021-12-23-a.

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug, Concurrency, Windows
Assignee None
Priority Medium

md5: 33cb31c018b26c413b20c4f4c1356a81

Issue Description:

When adding many tasks to a TaskGroup, the program crashes when waiting for the tasks to finish. This doesn't happen on "relatively low" values of upperBound. For example when upperBound = 2500, the code executes fine to the end and prints "Done: 2500". But when for example upperBound > 10000, the program crashes. I cannot reproduce this behavior on macOS or Linux.

@main
struct App {
    static func main() async {
        let upperBound = 10000
        await withTaskGroup(of: Void.self) { group in 
            for i in 0..<upperBound {
                group.addTask {
                    print(i)
                }
            }
        }
        print("Done:", upperBound)
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    ConcurrencуArea → standard library: The `Concurrency` module under the standard library umbrellaTaskGroupArea → standard library → Concurrency: The `TaskGroup` typeWindowsPlatform: WindowsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during executionstandard libraryArea: Standard library umbrellaswift 5.6

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions