Skip to content

[SR-6450] Leak in Process on Linux #4049

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

Closed
swift-ci opened this issue Nov 21, 2017 · 1 comment
Closed

[SR-6450] Leak in Process on Linux #4049

swift-ci opened this issue Nov 21, 2017 · 1 comment
Assignees

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-6450
Radar None
Original Reporter oc243 (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

DEVELOPMENT-SNAPSHOT-2017-11-16-a

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee @spevans
Priority Medium

md5: 48142a06d97c0f16ee65fee7f8fd4f74

Issue Description:

The following foundation code seems to leak in Linux and I don't think that it should:

import Foundation

func process() {
    while true {
        let p = Process()
        p.launchPath = "/bin/true"
        p.launch()
        p.waitUntilExit()
    }
}

process()

Running Valgrind on this states:

==2562== 144,536 (71,659 direct, 72,877 indirect) bytes in 203 blocks are definitely lost in loss record 148 of 150
==2562==    at 0x4C2DBF6: malloc (vg_replace_malloc.c:299)
==2562==    by 0x52EAD75: swift_slowAlloc (in /home/oliver/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2017-11-16-a/usr/lib/swift/linux/libswiftCore.so)
==2562==    by 0x52EADAE: _swift_allocObject_ (in /home/oliver/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2017-11-16-a/usr/lib/swift/linux/libswiftCore.so)
==2562==    by 0x59D485F: Foundation.Process.__allocating_init() -> Foundation.Process (in /home/oliver/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2017-11-16-a/usr/lib/swift/linux/libFoundation.so)
==2562==    by 0x10A36A: main.process() -> () (in /home/oliver/main)
==2562==    by 0x1099D3: main (in /home/oliver/main)
@spevans
Copy link
Contributor

spevans commented Jan 28, 2020

The runLoopSource was creating a retain cycle so it needed to be set to nil when the child process had finished.

#2631 should fix it.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from swiftlang/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants