File tree 2 files changed +13
-6
lines changed 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -634,19 +634,20 @@ open class FileHandle : NSObject {
634
634
readabilitySource = nil
635
635
privateAsyncVariablesLock. unlock ( )
636
636
637
- if closeFd {
638
637
#if os(Windows)
638
+ // SR-13822 - Not Closing the file descriptor on Windows causes a Stack Overflow
639
639
guard CloseHandle ( self . _handle) else {
640
640
throw _NSErrorWithWindowsError ( GetLastError ( ) , reading: true )
641
641
}
642
642
self . _handle = INVALID_HANDLE_VALUE
643
643
#else
644
- guard _close ( _fd) >= 0 else {
645
- throw _NSErrorWithErrno ( errno, reading: true )
644
+ if closeFd {
645
+ guard _close ( _fd) >= 0 else {
646
+ throw _NSErrorWithErrno ( errno, reading: true )
647
+ }
648
+ _fd = - 1
646
649
}
647
- _fd = - 1
648
650
#endif
649
- }
650
651
}
651
652
652
653
// MARK: -
Original file line number Diff line number Diff line change @@ -580,7 +580,7 @@ class TestFileHandle : XCTestCase {
580
580
}
581
581
}
582
582
583
- #if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
583
+ #if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT && !os(Windows)
584
584
func test_closeOnDealloc( ) throws {
585
585
try withTemporaryDirectory ( ) { ( url, path) in
586
586
let data = try XCTUnwrap ( " hello " . data ( using: . utf8) )
@@ -640,8 +640,14 @@ class TestFileHandle : XCTestCase {
640
640
( " test_nullDevice " , test_nullDevice) ,
641
641
( " testHandleCreationAndCleanup " , testHandleCreationAndCleanup) ,
642
642
( " testOffset " , testOffset) ,
643
+ ] )
644
+
645
+ #if !os(Windows)
646
+ tests. append ( contentsOf: [
647
+ /* ⚠️ SR-13822 - closeOnDealloc doesnt work on Windows and so this test is disabled there. */
643
648
( " test_closeOnDealloc " , test_closeOnDealloc) ,
644
649
] )
650
+ #endif
645
651
#endif
646
652
647
653
return tests
You can’t perform that action at this time.
0 commit comments