From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Cc: Johannes Khoshnazar-Thoma <johannes@johannesthoma.com>
Subject: Re: cygwin application hangs on closing console
Date: Fri, 28 Jun 2024 21:17:26 +0900 [thread overview]
Message-ID: <20240628211726.c131e0a300046d1fa46f6b53@nifty.ne.jp> (raw)
In-Reply-To: <95442cfe-a87c-4816-b337-b130e481e3f1@johannesthoma.com>
Sorry for very late replay.
On Mon, 3 Jun 2024 15:20:32 +0200
Johannes Khoshnazar-Thoma wrote:
> We did more testing and it looks like the name of the event
> that signals console master thread start and end is shared between
> unrelated processes (it uses the console minor which is always (?)
> 0 when running from a powershell).
>
> So since it is a two-state event (as opposed to a semaphore)
> in theory the following can happen:
>
> Process A Process B
> SetEvent(e)
> SetEvent(e)
> Waitforevent(e)
> Waitforevent(e)
This should not happen. Master thread is unique to console.
get_minor() number is always 0 for the first opened console.
If you open another powershell window and start cygwin process
while the first cygwin process is still active, the get_minor()
returns 1.
Waiting for thread_sync_event is executed only
if (shared_console_info[unit] && con.owner == myself->pid)
con.owner is in the shared memory which is shared among all
processes started in the same console. Therefore, only the
one process start to wait the event.
> The second SetEvent does nothing. As a result the
> later Waitforevent is stuck (which is what we observe).
>
> So the question is: why should this event be used in
> unrelated cygwin processes? Is there a technical reason
> we don't understand (yet) for doing that (sharing the event).
>
> We patched cygwin to use pseudo random event names (the
> tm_usec field of gettimeofday()) and the stuckness vanished.
> So unless there is a reason for sharing the event between
> cygwin processes this patch should work:
Do you really confirm that your patch resolves the issue?
If so, the cause might be some kind of race issue.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
next prev parent reply other threads:[~2024-06-28 12:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 12:50 Johannes Khoshnazar-Thoma
2024-04-22 18:51 ` Takashi Yano
2024-04-23 9:20 ` Johannes Khoshnazar-Thoma
2024-04-23 10:26 ` Takashi Yano
2024-05-15 15:37 ` Johannes Khoshnazar-Thoma
2024-05-15 15:48 ` Johannes Khoshnazar-Thoma
2024-05-15 20:24 ` Brian Inglis
2024-05-21 16:23 ` Johannes Khoshnazar-Thoma
2024-06-03 13:20 ` Johannes Khoshnazar-Thoma
2024-06-28 12:17 ` Takashi Yano [this message]
2024-06-28 15:32 ` Takashi Yano
2024-07-01 11:47 ` Johannes Khoshnazar-Thoma
2024-07-01 13:20 ` Takashi Yano
2024-07-01 13:36 ` Takashi Yano
2024-05-16 9:14 ` Takashi Yano
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=20240628211726.c131e0a300046d1fa46f6b53@nifty.ne.jp \
--to=takashi.yano@nifty.ne.jp \
--cc=cygwin@cygwin.com \
--cc=johannes@johannesthoma.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).