- 
                Notifications
    You must be signed in to change notification settings 
- Fork 45
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Consider the following code:
extension TrackedFileDescriptor {
    internal consuming func createPlatformDiskIO() -> TrackedPlatformDiskIO {
        let dispatchIO: DispatchIO = DispatchIO(
            type: .stream,
            fileDescriptor: self.platformDescriptor(),
            queue: .global(),
            cleanupHandler: { error in
                // Close the file descriptor
                if self.closeWhenDone {
                    try? self.safelyClose()
                }
            }
        )
        return .init(dispatchIO, closeWhenDone: self.closeWhenDone)
    }
}cleanupHandler is mis-annotated. It should be @Sendable but is not. This means the compiler allows the closure to capture a reference to and mutate self in concurrently-executing code, which it should not. It's unclear whether this is behaving as expected.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working