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-12084] EBADF when trying to close the Foundation's fileHandle of a pipe before running the task #4481

Closed
swift-ci opened this issue Jan 24, 2020 · 3 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-12084
Radar rdar://problem/58997147
Original Reporter rignatus (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 1
Component/s Foundation
Labels Bug, Crash
Assignee None
Priority Medium

md5: caf078cbdaea9431bcf4fecd701035b4

Issue Description:

description

The following program spawns /usr/bin/env and tries to close fileHandleForWriting for stdin.

This was run on Linux and it always crashes with: Fatal error: POSIX command failed with error: 9 – EBADF. On macOS works fine.

This affects Swift 5.1, but seems to be working on the latest master snapshot probably due to this PR.

program

import Foundation

let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/env")

let inputPipe = Pipe()
try! inputPipe.fileHandleForWriting.close()
process.standardInput = inputPipe
try! process.run() 

Repro:

on Linux

swift File.swift && ./File 

on macOS (via docker)

# assuming File.swift is in the working directory
docker run --privileged --rm -v "$PWD:$PWD" -w "$PWD" -it swift:5.1 bash -c 'swiftc File.swift && ./File' 
@weissi
Copy link
Member

weissi commented Jan 24, 2020

@swift-ci create

@spevans
Copy link
Collaborator

spevans commented Jan 24, 2020

The PR was backported to 5.1 in #2608 so should be in the 5.1.4 release

@spevans
Copy link
Collaborator

spevans commented Jun 5, 2020

This is working correcting in s{{wift-5.2-RELEASE-ubuntu18.04}}, swift-5.3-DEVELOPMENT-SNAPSHOT-2020-05-04-a-ubuntu18.04 and master

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/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

3 participants