Child from forkProcess calls select/read on parent's Handle, stealing data from parent
In trying out git-annex on a large repository, I ran into a strange bug where git-annex would try to operate on a filename that consisted of the beginning of one filename spliced together with the end of another filename. After staring at strace output for a while, I tracked down the problem, though not the root cause. git-annex would call pipeFrom (from MissingH's System.Cmd.Utils), which (by way of hPipeFrom) would call forkProcess to get a child process, and then call dupTo, close the original fd, and call execProcess to run the specified process. The parent process, in turn, would call fdToHandle on the other end of the pipe, and then pipeFrom would call hGetContents on that handle. In the version of git-annex I originally tested (the 0.04 release), more than one of these pipes might run at once. strace showed that on occasion, the child process created by forkProcess would call select on the file descriptor for a *previous* pipe, and read from that previous pipe, stealing data from the parent process; it would do this at some point after starting and before calling exec.
I reproduced this problem with 6.12.1 and 6.10.4, both with and without -threaded. The analysis of the strace given above came from 6.12.1 without -threaded. (Note that with -threaded, strace would fail at runtime, with "PANIC: attached pid $SOMEPID exited with 0"; see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=603187 . So, I don't have an strace to analyze from -threaded.)
I can reliably reproduce this problem. Please let me know if I can provide any further information.
Trac metadata
Trac field | Value |
---|---|
Version | 6.12.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Runtime System |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | joey@kitenet.net, josh@joshtriplett.org |
Operating system | |
Architecture |