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-7608: Pipe() crashes when the underlying system call fails. #1697
Conversation
- Pipe does not have a failable or throwable initializer but currently calls fatalError() for all errors returned from pipe(). - If pipe() returns EMFILE or ENFILE then set the fileDescriptor to -1 for both .fileHandleForReading and .fileHandleForWriting. For all other errors call fatalError(). - TestFileHandle.swift: Remove duplicate test_pipe(). - TestPipe.swift: Add extra test to try and exhaust the process's pipes. - Test the file descriptor is valid and open for certain methods and properties to match Darwin.
@swift-ci test |
Do we need to provide some new API on Darwin that avoids throwing an ObjC exception? |
On Darwin eg:
Will create about 1266 pipes on 10.13.6 before returning 0 for the file descriptors. Maybe this initialiser should be deprecated and a failable one introduced? |
Interesting. I'll track that with a radar for us. rdar://problem/44605663 |
// hard limit for the test. This is reached when testing on Linux (at around 488 pipes) | ||
// but not on macOS. | ||
|
||
var pipes: [Pipe] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried about this, because it means that the test process cannot use pipes meaningfully anywhere else.
Can we move this code to a separate process we spawn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the pipes should be closed when the array is cleared. test_MaxPipes
is run before test_Pipe
to test this very case.
@swift-ci test |
@swift-ci please test and merge |
Pipe does not have a failable or throwable initializer but currently
calls fatalError() for all errors returned from pipe().
If pipe() returns EMFILE or ENFILE then set the fileDescriptor
to -1 for both .fileHandleForReading and .fileHandleForWriting.
For all other errors call fatalError().
TestFileHandle.swift: Remove duplicate test_pipe().
TestPipe.swift: Add extra test to try and exhaust the process's pipes.
Test the file descriptor is valid and open for certain methods
and properties to match Darwin.