This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH 0/1] Fix deadlocks related to child processes
- From: David McFarland <corngood at gmail dot com>
- To: cygwin-patches at cygwin dot com
- Cc: David McFarland <corngood at gmail dot com>
- Date: Sun, 28 Oct 2018 16:22:43 -0300
- Subject: [PATCH 0/1] Fix deadlocks related to child processes
For a long time I've been struggling with intermittent deadlocks and
segfaults in emacs, seemingly related to invoking child processes. I
recently found a reliable way to reproduce one such deadlock:
- install clean cygwin with: emacs-w32, clang
- install flycheck from elpa
- grab some non trivial C header e.g.:
$ cp /usr/include/stdio.h test.h
- $ emacs -q test.h
- start flycheck:
(progn (package-initialize)
(require 'flycheck)
(flycheck-mode))
- add a character to the start of the first line
- wait for flygheck to complete
- repeat the last two steps until a deadlock occurs
Breaking in gdb showed the main thread in `cygheap_protect.acquire ()`,
from either _cfree or _cmalloc. The thread holding the mutex was always
"flasio", and it would either be continually segfaulting or looping in
_cfree.
I added some debug prints to cygheap and determined that it flasio was
double-freeing an atomic_write_buf. I added some more prints and found
that it was two different fhandler objects freeing the same buffer.
I then found that `fhandler_base_overlapped::copyto` would clear the
buffer pointer after the copy, but none of the derived classes (pipe,
fifo) did.
Attached is a patch which clears the buffer pointers when copying pipes
and fifos.
It would probably be safer to move the buffer clear to a `operator=`,
but I wanted to keep the patch as simple as possible and avoid
refactoring.
David McFarland (1):
Cygwin: Fix cygheap corruption caused by cloned atomic buffer
winsup/cygwin/fhandler.h | 2 ++
1 file changed, 2 insertions(+)
--
2.19.1