This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 0/1] Fix deadlocks related to child processes


On Oct 28 16:22, David McFarland wrote:
> 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.

Excellent detective work, thanks for the patch!  Pushed.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]