From: Ken Brown <kbrown@cornell.edu>
To: cygwin@cygwin.com
Subject: Re: Another pipe-related problem?
Date: Tue, 9 Nov 2021 21:53:35 -0500 [thread overview]
Message-ID: <bb6c5229-ce46-5fb3-c8c3-a19c0826d8d5@cornell.edu> (raw)
In-Reply-To: <75197fd0-d5da-3236-a7df-b8ffc3f67da7@cornell.edu>
On 11/9/2021 5:20 PM, Ken Brown via Cygwin wrote:
> On 11/9/2021 5:16 PM, Ken Brown via Cygwin wrote:
>> On 11/9/2021 9:11 AM, Ken Brown via Cygwin wrote:
>>> On 11/9/2021 5:55 AM, Henry S. Thompson wrote:
>>>> As you may know, the XEmacs situation is complicated. The old source
>>>> repo (bitbucket.org/xemacs) no longer exists. There's a fork that's
>>>> still being maintained, but it's not widely publicised. That's the
>>>> one I'm working with -- are you aware of this.
>>>
>>> I was aware that the bitbucket repo didn't exist, because I tried to get the
>>> sources there. But I didn't know about the fork. Please point me to it, or
>>> just make a tarball available to me somehow.
>>>
>>>> Here are the immediate contexts from the sources for the xemacs
>>>> sources in the above backtrace, might be enough to check your
>>>> hypothesis:
>>>>
>>>> sysdep.c:
>>>>
>>>> retry_read_1 (int fildes, void *buf, size_t nbyte, int allow_quit)
>>>> {
>>>> ssize_t rtnval;
>>>>
>>>> while ((rtnval = read (fildes, buf, nbyte)) == -1
>>>> && (errno == EINTR)) <<<<<<<<<<<<<<<<<<<<
>>>> {
>>>> if (allow_quit)
>>>> QUIT;
>>>> }
>>>> return rtnval;
>>>> }
>>> I'll have to reproduce the hang myself in order to test this (or maybe you
>>> could test it), but I now have a new guess: If the read call above keeps
>>> failing with EINTR, then we're in an infinite loop. This could happen
>>> because of the following code in fhandler_pipe::raw_read:
>>>
>>> DWORD waitret = cygwait (read_mtx, timeout);
>>> switch (waitret)
>>> {
>>> case WAIT_OBJECT_0:
>>> break;
>>> case WAIT_TIMEOUT:
>>> set_errno (EAGAIN);
>>> len = (size_t) -1;
>>> return;
>>> default:
>>> set_errno (EINTR);
>>> len = (size_t) -1;
>>> return;
>>> }
>>>
>>> Takashi, is EINTR really the appropriate errno in the default case? Isn't
>>> cygwait supposed to handle signals?
>>
>> I was able to build XEmacs and reproduce the problem. My guess was wrong,
>> though my question to Takashi still stands. I think the infinite loop is
>> actually caused by a bug in fhandler_pipe::raw_read that only affects
>> non-blocking pipes (which is what we have in XEmacs).
>>
>> Consider the following code in fhandler_pipe::raw_read:
>>
>> status = NtReadFile (get_handle (), evt, NULL, NULL, &io, ptr,
>> len1, NULL, NULL);
>> if (evt && status == STATUS_PENDING) <<<<<<<<<<<<<<<<<<<<<<<<<<<<
>> {
>> waitret = cygwait (evt, INFINITE, cw_cancel | cw_sig);
>> [...]
>> }
>>
>> In the non-blocking case, evt == NULL, but we still might have status ==
>> STATUS_PENDING. We then should wait on get_handle() to let NtReadFile finish.
>> By not waiting, we end up using a garbage value from io.Information, leading
>> to an infinite loop in drain_signal_event_pipe.
Nope, that doesn't seem to be the issue. Even after fixing this, I still see an
infinite loop. Probably NtReadFile finishes quickly enough that io.Information
is in fact valid by the time we test it. Back to the drawing board.
> BTW, a quick glance at raw_write suggests that there might be a similar bug
> there, but I'll have to look more closely.
Ken
next prev parent reply other threads:[~2021-11-10 2:53 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 [this message]
2021-11-10 3:51 ` Backwoods BC
2021-11-10 14:47 ` Ken Brown
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=bb6c5229-ce46-5fb3-c8c3-a19c0826d8d5@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).