[SR-15522] Process.run() fails with "Bad file descriptor" after a few thousand invocations. #57827
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Attachment: Download
Environment
Tested on macOS 12.0.1, Xcode 13.1 with Swift 5.5.1 as well as on Ubuntu 20.04 on an arm64 machine, again with Swift 5.5.1.
Additional Detail from JIRA
md5: c5bdfb2ddbfe3ef6f3a5262fa7026ab1
Issue Description:
If you create a loop that continuously creates and runs Process objects, the run call will fail after a little while - how long seems to depend on the platform in mysterious ways, but a number of thousands typically.
The code in question also creates Pipe objects for input and output, but I have not yet tested if this affects the bug or not.
When run inside Xcode, the provided code crashes on iteration 9465. When run on the same macOS machine using
swift run
, it crashes on iteration 4855. When run usingswift run
on an arm64 Linux machine using Ubuntu 20.04, it crashes on iteration 2023.The crash is:
Bugtest/main.swift:17: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSPOSIXErrorDomain Code=9 "Bad file descriptor"
The text was updated successfully, but these errors were encountered: