public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: cygwin@cygwin.com
Subject: Re: Another pipe-related problem?
Date: Wed, 10 Nov 2021 09:47:31 -0500	[thread overview]
Message-ID: <4b937b32-e348-19d2-2406-c55fa12e20a3@cornell.edu> (raw)
In-Reply-To: <bb6c5229-ce46-5fb3-c8c3-a19c0826d8d5@cornell.edu>

On 11/9/2021 9:53 PM, Ken Brown via Cygwin wrote:
> Back to the drawing board.

It finally occurred to me to stop looking for a bug in fhandler_pipe::raw_read 
and instead see if something is in fact repeatedly writing to the pipe, so that 
drain_signal_event_pipe never finishes.  Putting a breakpoint at 
fhandler_pipe::raw_write, I found that this is in fact the case.  While the main 
thread is repeatedly reading from the pipe, a second thread is repeatedly 
writing to it.  Here's the backtrace of that thread:

#0  fhandler_pipe_fifo::raw_write (this=0x18039f370, ptr=0x2c4ca3b, len=1)
     at ../../../../temp/winsup/cygwin/fhandler_pipe.cc:430
#1  0x000000018006f39a in fhandler_base::write (this=0x18039f370,
     ptr=0x2c4ca3b, len=1) at ../../../../temp/winsup/cygwin/fhandler.cc:907
#2  0x0000000180158fd1 in write (fd=4, ptr=0x2c4ca3b, len=1)
     at ../../../../temp/winsup/cygwin/syscalls.cc:1360
#3  0x00000001801b9b5b in _sigfe () at sigfe.s:35
#4  0x00000001006ae471 in retry_write_1 (fildes=4, buf=0x2c4ca3b, nbyte=1,
     allow_quit=0) at sysdep.c:2364
#5  0x00000001006ae581 in retry_write (fildes=4, buf=0x2c4ca3b, nbyte=1)
     at sysdep.c:2386
#6  0x00000001004b3ba5 in signal_fake_event () at event-unixoid.c:149
#7  0x0000000100691060 in alarm_signal (signo=14) at signal.c:559
#8  0x00000001006ec6e4 in mswindows_raise (nsig=14) at win32.c:694
#9  0x00000001006ec72d in setitimer_helper_proc (unused_uID=96, unused_uMsg=0,
     dwUser=14, unused_dw1=0, unused_dw2=0) at win32.c:742
#10 0x00007ffb363c2811 in WINMM!PlaySoundW () from /c/WINDOWS/SYSTEM32/WINMM.dll
#11 0x000000018004771c in _cygtls::call2 (this=0x2c4ce00,
     func=0x7ffb363c26c0 <WINMM!PlaySoundW+3440>, arg=0x0, buf=0x2c4cce0)
     at ../../../../temp/winsup/cygwin/cygtls.cc:40
#12 0x00000001800476c1 in _cygtls::call (
     func=0x7ffb363c26c0 <WINMM!PlaySoundW+3440>, arg=0x0)
     at ../../../../temp/winsup/cygwin/cygtls.cc:27
#13 0x00000001800e4f15 in threadfunc_fe (arg=0x0)
     at ../../../../temp/winsup/cygwin/init.cc:28
#14 0x00007ffb43da7034 in KERNEL32!BaseThreadInitThunk ()
    from /c/WINDOWS/System32/KERNEL32.DLL
#15 0x00007ffb448c2651 in ntdll!RtlUserThreadStart ()
    from /c/WINDOWS/SYSTEM32/ntdll.dll
#16 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

This looks to me like an XEmacs bug that happens to be triggered by the new pipe 
code, although maybe there's also a Cygwin bug that I'm not seeing.  The comment 
at the beginning of signal_fake_event might be relevant:

void
signal_fake_event (void)
{
   Rawbyte rbyte = 0;
   /* We do the write always.  Formerly I tried to "optimize" this
      by setting a flag indicating whether we're blocking and only
      doing the write in that case, but there is a race condition
      if the signal occurs after we've checked for the signal
      occurrence (which could occur in many places throughout
      an iteration of the command loop, e.g. in status_notify()),
      but before we set the blocking flag.

      This should be OK as long as write() is reentrant, which I'm fairly
      sure it is since it's a system call. */

   if (signal_event_pipe_initialized)
     /* In case a signal comes through while we're dumping */
     {
       int old_errno = errno;
       retry_write (signal_event_pipe[1], &rbyte, 1);
       errno = old_errno;
     }
}

Ken

  parent reply	other threads:[~2021-11-10 14:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08 13:12 Henry S. Thompson
2021-11-08 14:35 ` Ken Brown
2021-11-08 18:52   ` Ken Brown
2021-11-09 10:55   ` Henry S. Thompson
2021-11-09 14:11     ` Ken Brown
2021-11-09 14:47       ` Henry S. Thompson
2021-11-09 22:16       ` Ken Brown
2021-11-09 22:20         ` Ken Brown
2021-11-10  2:53           ` Ken Brown
2021-11-10  3:51             ` Backwoods BC
2021-11-10 14:47             ` Ken Brown [this message]
2021-11-10 17:23               ` Henry S. Thompson
2021-11-10 18:03                 ` Ken Brown
2021-11-10 18:42                   ` Henry S. Thompson
2021-11-10 23:07                     ` Andrey Repin
2021-11-11 11:06                       ` Andrey Repin
2021-11-11 14:16                     ` Ken Brown
2021-12-08 21:09                     ` XEmacs versus Cygwin 3.3 (was Re: Another pipe-related problem?) Henry S. Thompson
2021-12-09  8:39                       ` Aidan Kehoe
2021-11-09 23:22       ` Another pipe-related problem? Takashi Yano
2021-11-09 23:29         ` Takashi Yano
2021-11-09 23:48           ` Takashi Yano
2021-11-10  0:16             ` Takashi Yano
2021-11-10  0:37               ` Takashi Yano
2021-11-10  2:02                 ` Ken Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4b937b32-e348-19d2-2406-c55fa12e20a3@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).