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-14973] withTaskGroup leaks memory for every task added to the group #57315

Closed
swift-ci opened this issue Jul 25, 2021 · 5 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-14973
Radar rdar://problem/81130259
Original Reporter Orobio (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

swift-5.5-DEVELOPMENT-SNAPSHOT-2021-07-23-a-ubuntu20.04

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, Concurrency
Assignee @ktoso
Priority Medium

md5: 4b6e62352672f083453f505793e86e64

relates to:

  • SR-15175 withTaskGroup(of:) leaks huge amounts of memory on linux

Issue Description:

Memory is malloc'ed for every task in the TaskGroup, which is never released.

The following:

await withTaskGroup(of: Int.self) { group in
    for i in 1...1234 {
        group.addTask { return i }
    }

    while let result = await group.next() {
        print(result)
    }
}

Results in:

valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all .build/debug/TestApp
...
...
414,624 bytes in 1,234 blocks are still reachable in loss record 48 of 48
    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x4E2B917: swift_task_create_common (in /usr/lib/swift/linux/libswift_Concurrency.so)
    by 0x185CCF: $sScG7addTask8priority9operationyScPSg_xyYaYbcntF (<compiler-generated>:0)
    by 0x188E0C: $s7TestApp8runGroupSSyYaFyScGySiGzYaXEfU_ (main.swift:18)
    by 0x4E294EA: swift::runJobInEstablishedExecutorContext(swift::Job*) (in /usr/lib/swift/linux/libswift_Concurrency.so)
    by 0x4E29C87: swift_job_run (in /usr/lib/swift/linux/libswift_Concurrency.so)
    by 0x4EAE2A6: _dispatch_worker_thread (in /usr/lib/swift/linux/libdispatch.so)
    by 0x5864608: start_thread (pthread_create.c:477)
    by 0x59FE292: clone (clone.S:95)
...
...
@typesanitizer
Copy link

@swift-ci create

@ktoso
Copy link
Member

ktoso commented Sep 3, 2021

Working on a fix here: #39158

@tayloraswift
Copy link
Contributor

possibly related: SR-15175

@ktoso
Copy link
Member

ktoso commented Sep 14, 2021

It was two separate issues, one fixed by #39158 and the other (including SR-15175 causing) fixed by #39295

@ktoso
Copy link
Member

ktoso commented Sep 14, 2021

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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. concurrency Feature: umbrella label for concurrency language features standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

4 participants