FB11837553
Ah, OK, looking at that bug it seems that our best guess as to what’s going wrong here is that something within your process is closing a flow divert file descriptor. This is a pretty common failure mode with the Unix file system API. It generally goes down something like this:
-
Subsystem A opens a file, getting file descriptor X.
-
Subsystem A closes file descriptor X.
-
Subsystem B opens a file descriptor and gets the first unused file descriptor, which just happens to be X.
-
Subsystem A accidentally closes file descriptor X again.
At this point subsystem B fails because its file descriptor was closed out from underneath it.
Debugging problems like this is a pain. Your best option is to put a guard on file descriptor X, which causes a trap if the person closing the file descriptor doesn’t remove the guard first. This is, for example, what Core Data does [1].
However, the guard facility isn’t API and you don’t own the file descriptor, both of which make this technique challenging.
One thing you could do is run fs_usage
to watch the descriptor opens and closes in your process.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] ’cause they got sick of fielding bug reports against Core Data that were caused by folks accidentally closing file descriptors out from underneath it.