public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* cygwin application hangs on closing console
@ 2024-04-22 12:50 Johannes Khoshnazar-Thoma
  2024-04-22 18:51 ` Takashi Yano
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Khoshnazar-Thoma @ 2024-04-22 12:50 UTC (permalink / raw)
  To: The Cygwin Mailing List

Hi cygwin team :)

I have found something what may be a cygwin bug. Sometimes
(1 out of 1000 times) a drbdadm.exe process (which is part of WinDRBD's
user mode programs originally written for Linux) hangs for several
days on exiting (closing the console). I got a minidump and analyzed
the dump with gdb (the minidump enabled version at https://github.com/ssbssa/gdb)

I have to note that the application (drbdadm.exe) is run from a
Windows Service. Furthermore it is not a full cygwin installation
however the cygwin1.dll (3.4.10-1) is in the $PATH.

here is the gdb output:

(gdb) info thread
   Id   Target Id         Frame
* 1    Thread 0x14c8     0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   2    Thread 0x2e0      0x00007ffc6a405ee4 in ntdll!ZwReadFile () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   3    Thread 0x1060     0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   4    Thread 0x858      0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   5    Thread 0xe40      0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) thread 1
[Switching to thread 1 (Thread 0x14c8)]
#0  0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffc66826d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\6502815021e000\KERNELBASE.dll
#2  0x00007ffc492ebb42 in fhandler_console::close (this=0x800007f20) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/fhandler/console.cc:1769
#3  0x00007ffc492dc365 in fhandler_base::close_with_arch (this=0x800007f20) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/fhandler/base.cc:1202
#4  0x00007ffc49353640 in init_cygheap::close_ctty (this=<optimized out>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/mm/cygheap.cc:133
#5  0x00007ffc492aee9f in close_all_files (norelease=norelease@entry=false) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/syscalls.cc:81
#6  0x00007ffc49226763 in do_exit (status=0) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/dcrt0.cc:1125
#7  0x00007ffc4922693f in _exit (n=<optimized out>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/dcrt0.cc:1240
#8  0x00007ffc49390899 in exit (code=0) at /usr/src/debug/cygwin-3.4.10-1/newlib/libc/stdlib/exit.c:65
#9  0x00007ffc49226923 in cygwin_exit (n=568) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/dcrt0.cc:1234
#10 0x00007ffc492280aa in dll_crt0_1 () at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/dcrt0.cc:999
#11 0x00007ffc49225c86 in _cygtls::call2 (this=0x7ffffce00, func=0x7ffc49226f80 <dll_crt0_1(void*)>, arg=0x0, buf=buf@entry=0x7ffffcdf0) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:41
#12 0x00007ffc49225d34 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:28
#13 0x0000000000000000 in ?? ()
(gdb) thread 1
[Switching to thread 1 (Thread 0x14c8)]
#0  0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) info thread
   Id   Target Id         Frame
* 1    Thread 0x14c8     0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   2    Thread 0x2e0      0x00007ffc6a405ee4 in ntdll!ZwReadFile () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   3    Thread 0x1060     0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   4    Thread 0x858      0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   5    Thread 0xe40      0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffc66826d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\6502815021e000\KERNELBASE.dll
#2  0x00007ffc492ebb42 in fhandler_console::close (this=0x800007f20) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/fhandler/console.cc:1769
#3  0x00007ffc492dc365 in fhandler_base::close_with_arch (this=0x800007f20) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/fhandler/base.cc:1202
#4  0x00007ffc49353640 in init_cygheap::close_ctty (this=<optimized out>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/mm/cygheap.cc:133
#5  0x00007ffc492aee9f in close_all_files (norelease=norelease@entry=false) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/syscalls.cc:81
#6  0x00007ffc49226763 in do_exit (status=0) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/dcrt0.cc:1125
#7  0x00007ffc4922693f in _exit (n=<optimized out>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/dcrt0.cc:1240
#8  0x00007ffc49390899 in exit (code=0) at /usr/src/debug/cygwin-3.4.10-1/newlib/libc/stdlib/exit.c:65
#9  0x00007ffc49226923 in cygwin_exit (n=568) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/dcrt0.cc:1234
#10 0x00007ffc492280aa in dll_crt0_1 () at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/dcrt0.cc:999
#11 0x00007ffc49225c86 in _cygtls::call2 (this=0x7ffffce00, func=0x7ffc49226f80 <dll_crt0_1(void*)>, arg=0x0, buf=buf@entry=0x7ffffcdf0) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:41
#12 0x00007ffc49225d34 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:28
#13 0x0000000000000000 in ?? ()
(gdb) thread 2
[Switching to thread 2 (Thread 0x2e0)]
#0  0x00007ffc6a405ee4 in ntdll!ZwReadFile () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffc6a405ee4 in ntdll!ZwReadFile () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffc6682e704 in ReadFile () from C:\src\dlls-syms\KERNELBASE.dll\6502815021e000\KERNELBASE.dll
#2  0x00007ffc4929f541 in wait_sig () at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/sigproc.cc:1331
#3  0x00007ffc49224aa3 in cygthread::callfunc (this=this@entry=0x7ffc49416880 <threads>, issimplestub=issimplestub@entry=false) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygthread.cc:48
#4  0x00007ffc49225066 in cygthread::stub (arg=arg@entry=0x7ffc49416880 <threads>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygthread.cc:91
#5  0x00007ffc49225c86 in _cygtls::call2 (this=0x10ece00, func=0x7ffc49224fe0 <cygthread::stub(void*)>, arg=0x7ffc49416880 <threads>, buf=buf@entry=0x10ecd50) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:41
#6  0x00007ffc49225d34 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:28
#7  0x00007ffc691584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#8  0x00007ffc6a3b1791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#9  0x0000000000000000 in ?? ()
(gdb) thread 3
[Switching to thread 3 (Thread 0x1060)]
#0  0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffc66826d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\6502815021e000\KERNELBASE.dll
#2  0x00007ffc492250a1 in cygthread::stub (arg=arg@entry=0x7ffc494168d8 <threads+88>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygthread.cc:112
#3  0x00007ffc49225c86 in _cygtls::call2 (this=0x19bce00, func=0x7ffc49224fe0 <cygthread::stub(void*)>, arg=0x7ffc494168d8 <threads+88>, buf=buf@entry=0x19bcd50) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:41
#4  0x00007ffc49225d34 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:28
#5  0x00007ffc691584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#6  0x00007ffc6a3b1791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#7  0x0000000000000000 in ?? ()
(gdb) thread 4
[Switching to thread 4 (Thread 0x858)]
#0  0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffc66826d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\6502815021e000\KERNELBASE.dll
#2  0x00007ffc492250a1 in cygthread::stub (arg=arg@entry=0x7ffc49416930 <threads+176>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygthread.cc:112
#3  0x00007ffc49225c86 in _cygtls::call2 (this=0x22fce00, func=0x7ffc49224fe0 <cygthread::stub(void*)>, arg=0x7ffc49416930 <threads+176>, buf=buf@entry=0x22fcd50) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:41
#4  0x00007ffc49225d34 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:28
#5  0x00007ffc691584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#6  0x00007ffc6a3b1791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#7  0x0000000000000000 in ?? ()
(gdb) thread 5
[Switching to thread 5 (Thread 0xe40)]
#0  0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffc66826d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\6502815021e000\KERNELBASE.dll
#2  0x00007ffc492250a1 in cygthread::stub (arg=arg@entry=0x7ffc49416988 <threads+264>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygthread.cc:112
#3  0x00007ffc49225c86 in _cygtls::call2 (this=0x24fce00, func=0x7ffc49224fe0 <cygthread::stub(void*)>, arg=0x7ffc49416988 <threads+264>, buf=buf@entry=0x24fcd50) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:41
#4  0x00007ffc49225d34 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/cygtls.cc:28
#5  0x00007ffc691584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#6  0x00007ffc6a3b1791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#7  0x0000000000000000 in ?? ()
(gdb) p master_thread_started
$7 = true
(gdb) thread 1
[Switching to thread 1 (Thread 0x14c8)]
#0  0x00007ffc6a405ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) up
#1  0x00007ffc66826d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\6502815021e000\KERNELBASE.dll
(gdb)
#2  0x00007ffc492ebb42 in fhandler_console::close (this=0x800007f20) at /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/fhandler/console.cc:1769
1769    in /usr/src/debug/cygwin-3.4.10-1/winsup/cygwin/fhandler/console.cc
(gdb) p name
$8 = "cygcons.thread_sync.0", '\000' <repeats 19 times>, "r", '\000' <repeats 151 times>, "^8\025\r!‘\000\000"...
(gdb) p myself
$9 = {<pinfo_minimal> = {h = 0x118, hProcess = 0x0, rd_proc_pipe = 0x0}, destroy = false, winpid_hdl = 0x11c, procinfo = 0x1a2000000, waiter_ready = false, wait_thread = 0x0}

It looks like the cons_master_thread already exited, maybe clearing the master_thread_started
flag in that case helps? but this is only a wild guess ...

If you need more information, please let me know.

Thanks a lot and Best regards,

- Johannes

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: cygwin application hangs on closing console
  2024-04-22 12:50 cygwin application hangs on closing console Johannes Khoshnazar-Thoma
@ 2024-04-22 18:51 ` Takashi Yano
  2024-04-23  9:20   ` Johannes Khoshnazar-Thoma
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Yano @ 2024-04-22 18:51 UTC (permalink / raw)
  To: cygwin; +Cc: Johannes Khoshnazar-Thoma

On Mon, 22 Apr 2024 14:50:51 +0200
Johannes Khoshnazar-Thoma wrote:
> Hi cygwin team :)
> 
> I have found something what may be a cygwin bug. Sometimes
> (1 out of 1000 times) a drbdadm.exe process (which is part of WinDRBD's
> user mode programs originally written for Linux) hangs for several
> days on exiting (closing the console). I got a minidump and analyzed
> the dump with gdb (the minidump enabled version at https://github.com/ssbssa/gdb)
> 
> I have to note that the application (drbdadm.exe) is run from a
> Windows Service. Furthermore it is not a full cygwin installation
> however the cygwin1.dll (3.4.10-1) is in the $PATH.

Thanks for the report. Could you please test cygwin1.dll 3.5.3-1
wihch is the latest cygwin release?

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: cygwin application hangs on closing console
  2024-04-22 18:51 ` Takashi Yano
@ 2024-04-23  9:20   ` Johannes Khoshnazar-Thoma
  2024-04-23 10:26     ` Takashi Yano
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Khoshnazar-Thoma @ 2024-04-23  9:20 UTC (permalink / raw)
  To: cygwin

Am 22.04.24 um 20:51 schrieb Takashi Yano:
> On Mon, 22 Apr 2024 14:50:51 +0200
> Johannes Khoshnazar-Thoma wrote:
>> Hi cygwin team :)
>>
>> I have found something what may be a cygwin bug. Sometimes
>> (1 out of 1000 times) a drbdadm.exe process (which is part of WinDRBD's
>> user mode programs originally written for Linux) hangs for several
>> days on exiting (closing the console). I got a minidump and analyzed
>> the dump with gdb (the minidump enabled version at https://github.com/ssbssa/gdb)
>>
>> I have to note that the application (drbdadm.exe) is run from a
>> Windows Service. Furthermore it is not a full cygwin installation
>> however the cygwin1.dll (3.4.10-1) is in the $PATH.
>
> Thanks for the report. Could you please test cygwin1.dll 3.5.3-1
> wihch is the latest cygwin release?
>
Thanks for your reply.

Yes, sure, will test it with 3.5.3 as well. Due to round trip times
with the client this may take one or 2 weeks, however.

Just wanted to ask if the 3.4 branch is end of life?

Best regards,

- Johannes

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: cygwin application hangs on closing console
  2024-04-23  9:20   ` Johannes Khoshnazar-Thoma
@ 2024-04-23 10:26     ` Takashi Yano
  2024-05-15 15:37       ` Johannes Khoshnazar-Thoma
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Yano @ 2024-04-23 10:26 UTC (permalink / raw)
  To: cygwin; +Cc: Johannes Khoshnazar-Thoma

On Tue, 23 Apr 2024 11:20:16 +0200
Johannes Khoshnazar-Thoma wrote:
> Am 22.04.24 um 20:51 schrieb Takashi Yano:
> > On Mon, 22 Apr 2024 14:50:51 +0200
> > Johannes Khoshnazar-Thoma wrote:
> >> Hi cygwin team :)
> >>
> >> I have found something what may be a cygwin bug. Sometimes
> >> (1 out of 1000 times) a drbdadm.exe process (which is part of WinDRBD's
> >> user mode programs originally written for Linux) hangs for several
> >> days on exiting (closing the console). I got a minidump and analyzed
> >> the dump with gdb (the minidump enabled version at https://github.com/ssbssa/gdb)
> >>
> >> I have to note that the application (drbdadm.exe) is run from a
> >> Windows Service. Furthermore it is not a full cygwin installation
> >> however the cygwin1.dll (3.4.10-1) is in the $PATH.
> >
> > Thanks for the report. Could you please test cygwin1.dll 3.5.3-1
> > wihch is the latest cygwin release?
> >
> Thanks for your reply.
> 
> Yes, sure, will test it with 3.5.3 as well. Due to round trip times
> with the client this may take one or 2 weeks, however.

Thanks in advance.

> Just wanted to ask if the 3.4 branch is end of life?

3.4 branch: no more bug fix nor release.
3.5 branch: bug fix releases only.
3.6 branch: will be released with new features.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: cygwin application hangs on closing console
  2024-04-23 10:26     ` Takashi Yano
@ 2024-05-15 15:37       ` Johannes Khoshnazar-Thoma
  2024-05-15 15:48         ` Johannes Khoshnazar-Thoma
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Khoshnazar-Thoma @ 2024-05-15 15:37 UTC (permalink / raw)
  To: Takashi Yano, cygwin

Hi again,

Am 23.04.24 um 12:26 schrieb Takashi Yano:
>>> Thanks for the report. Could you please test cygwin1.dll 3.5.3-1
>>> wihch is the latest cygwin release?
>>>

We retried the tests with cygwin1.dll 3.5.3-1 and it looks like
the issue is still there. Here's an excerpt from the gdb debug
session:

(gdb) info thread
   Id   Target Id         Frame                                                                                                                                                                                                               * 1    Thread 0x11cc     0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   2    Thread 0x8ec      0x00007ffe579d5ee4 in ntdll!ZwReadFile () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   3    Thread 0x55c      0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll                                                                                                         4    Thread 0x131c     0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   5    Thread 0x9b8      0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll                                                                                               (gdb) thread 1
[Switching to thread 1 (Thread 0x11cc)]                                                                                                                                                                                                      #0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffe54156d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
#2  0x00007ffe4a2033a0 in fhandler_console::close (this=0x800009030) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc:1914
#3  0x00007ffe4a1f6ce7 in fhandler_base::close_with_arch (this=0x800009030) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/base.cc:1288
#4  0x00007ffe4a26a4cd in init_cygheap::close_ctty (this=0x800000000) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/mm/cygheap.cc:135
#5  0x00007ffe4a1c7c4e in close_all_files (norelease=norelease@entry=false) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/syscalls.cc:81
#6  0x00007ffe4a146840 in do_exit (status=0) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1128
#7  0x00007ffe4a1469f7 in _exit (n=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1243
#8  0x00007ffe4a2a4bb9 in exit (code=0) at /usr/src/debug/cygwin-3.5.3-1/newlib/libc/stdlib/exit.c:65
#9  0x00007ffe4a1469e7 in cygwin_exit (n=5392) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1237
#10 0x00007ffe4a14809a in dll_crt0_1 () at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1002
#11 0x00007ffe4a145e08 in _cygtls::call2 (this=0x7ffffce00, func=0x7ffe4a146fb8 <dll_crt0_1(void*)>, arg=0x0, buf=buf@entry=0x7ffffcdf0) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
#12 0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
#13 0x0000000000000000 in ?? ()
(gdb) thread 2
[Switching to thread 2 (Thread 0x8ec)]
#0  0x00007ffe579d5ee4 in ntdll!ZwReadFile () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffe579d5ee4 in ntdll!ZwReadFile () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffe5415e704 in ReadFile () from C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
#2  0x00007ffe4a1bada6 in wait_sig () at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/sigproc.cc:1324
#3  0x00007ffe4a144d5f in cygthread::callfunc (this=this@entry=0x7ffe4a335560 <threads>, issimplestub=issimplestub@entry=false) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygthread.cc:48
#4  0x00007ffe4a145270 in cygthread::stub (arg=arg@entry=0x7ffe4a335560 <threads>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygthread.cc:91
#5  0x00007ffe4a145e08 in _cygtls::call2 (this=0xdbce00, func=0x7ffe4a1451ea <cygthread::stub(void*)>, arg=0x7ffe4a335560 <threads>, buf=buf@entry=0xdbcd50) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
#6  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
#7  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#8  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#9  0x0000000000000000 in ?? ()
(gdb) thread 3
[Switching to thread 3 (Thread 0x55c)]
#0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffe54156d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
#2  0x00007ffe4a1452ab in cygthread::stub (arg=arg@entry=0x7ffe4a3355b8 <threads+88>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygthread.cc:112
#3  0x00007ffe4a145e08 in _cygtls::call2 (this=0x2aece00, func=0x7ffe4a1451ea <cygthread::stub(void*)>, arg=0x7ffe4a3355b8 <threads+88>, buf=buf@entry=0x2aecd50) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
#4  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
#5  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#6  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#7  0x0000000000000000 in ?? ()
(gdb) thread 4
[Switching to thread 4 (Thread 0x131c)]
#0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffe5794eb5e in ntdll!RtlReleaseSRWLockExclusive () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#2  0x00007ffe4a145e08 in _cygtls::call2 (this=0x323ce00, func=0x7ffe5794e3f0 <ntdll!RtlReleaseSRWLockExclusive+8704>, arg=0xc0b60, buf=buf@entry=0x323cd50) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
#3  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
#4  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#5  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#6  0x0000000000000000 in ?? ()
(gdb) thread 5
[Switching to thread 5 (Thread 0x9b8)]
#0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffe5794eb5e in ntdll!RtlReleaseSRWLockExclusive () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#2  0x00007ffe4a145e08 in _cygtls::call2 (this=0x343ce00, func=0x7ffe5794e3f0 <ntdll!RtlReleaseSRWLockExclusive+8704>, arg=0xc0b60, buf=buf@entry=0x343cd50) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
#3  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
#4  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#5  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#6  0x0000000000000000 in ?? ()
(gdb) thread 6
Unknown thread 6.
(gdb) thread 1
[Switching to thread 1 (Thread 0x11cc)]
#0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) up
#1  0x00007ffe54156d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
(gdb)
#2  0x00007ffe4a2033a0 in fhandler_console::close (this=0x800009030) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc:1914
1914    in /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc
(gdb) p thread_sync_event
$6 = (HANDLE) 0x1510
(gdb) p name
$7 = "cygcons.thread_sync.0", '\000' <repeats 19 times>, "r", '\000' <repeats 183 times>...
(gdb) p con.owner
No symbol "con" in current context.
(gdb) p master_thread_started
$8 = true
(gdb) p unit
$9 = 0
(gdb) p shared_console_info
$10 = {0x1a0030000, 0x0 <repeats 64 times>}
(gdb)

It looks like the master_thread already exited while thread 1 is waiting for some event
to be set (but I am not at all a cygwin expert). The executable (drbdsetup.exe) was running
from a Windows Service.

Please reach out if you need more information.

Best regards,

- Johannes

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: cygwin application hangs on closing console
  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-16  9:14           ` Takashi Yano
  0 siblings, 2 replies; 8+ messages in thread
From: Johannes Khoshnazar-Thoma @ 2024-05-15 15:48 UTC (permalink / raw)
  To: Takashi Yano, cygwin

Hi again,

Am 15.05.24 um 17:37 schrieb Johannes Khoshnazar-Thoma:
> Hi again,
>
> Am 23.04.24 um 12:26 schrieb Takashi Yano:
>>>> Thanks for the report. Could you please test cygwin1.dll 3.5.3-1
>>>> wihch is the latest cygwin release?
>>>>
>
> We retried the tests with cygwin1.dll 3.5.3-1 and it looks like
> the issue is still there. Here's an excerpt from the gdb debug
> session:
>
Sorry somehow the formatting got messed up I try again:

(gdb) info thread
   Id   Target Id         Frame
* 1    Thread 0x11cc     0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   2    Thread 0x8ec      0x00007ffe579d5ee4 in ntdll!ZwReadFile () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   3    Thread 0x55c      0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   4    Thread 0x131c     0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
   5    Thread 0x9b8      0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) thread 1
[Switching to thread 1 (Thread 0x11cc)]
#0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffe54156d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
#2  0x00007ffe4a2033a0 in fhandler_console::close (this=0x800009030) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc:1914
#3  0x00007ffe4a1f6ce7 in fhandler_base::close_with_arch (this=0x800009030) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/base.cc:1288
#4  0x00007ffe4a26a4cd in init_cygheap::close_ctty (this=0x800000000) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/mm/cygheap.cc:135
#5  0x00007ffe4a1c7c4e in close_all_files (norelease=norelease@entry=false) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/syscalls.cc:81
#6  0x00007ffe4a146840 in do_exit (status=0) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1128
#7  0x00007ffe4a1469f7 in _exit (n=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1243
#8  0x00007ffe4a2a4bb9 in exit (code=0) at /usr/src/debug/cygwin-3.5.3-1/newlib/libc/stdlib/exit.c:65
#9  0x00007ffe4a1469e7 in cygwin_exit (n=5392) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1237
#10 0x00007ffe4a14809a in dll_crt0_1 () at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1002
#11 0x00007ffe4a145e08 in _cygtls::call2 (this=0x7ffffce00, func=0x7ffe4a146fb8 <dll_crt0_1(void*)>, arg=0x0, buf=buf@entry=0x7ffffcdf0) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
#12 0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
#13 0x0000000000000000 in ?? ()
(gdb) thread 2
[Switching to thread 2 (Thread 0x8ec)]
#0  0x00007ffe579d5ee4 in ntdll!ZwReadFile () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffe579d5ee4 in ntdll!ZwReadFile () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffe5415e704 in ReadFile () from C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
#2  0x00007ffe4a1bada6 in wait_sig () at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/sigproc.cc:1324
#3  0x00007ffe4a144d5f in cygthread::callfunc (this=this@entry=0x7ffe4a335560 <threads>, issimplestub=issimplestub@entry=false) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygthread.cc:48
#4  0x00007ffe4a145270 in cygthread::stub (arg=arg@entry=0x7ffe4a335560 <threads>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygthread.cc:91
#5  0x00007ffe4a145e08 in _cygtls::call2 (this=0xdbce00, func=0x7ffe4a1451ea <cygthread::stub(void*)>, arg=0x7ffe4a335560 <threads>, buf=buf@entry=0xdbcd50) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
#6  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
#7  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#8  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#9  0x0000000000000000 in ?? ()
(gdb) thread 3
[Switching to thread 3 (Thread 0x55c)]
#0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffe54156d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
#2  0x00007ffe4a1452ab in cygthread::stub (arg=arg@entry=0x7ffe4a3355b8 <threads+88>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygthread.cc:112
#3  0x00007ffe4a145e08 in _cygtls::call2 (this=0x2aece00, func=0x7ffe4a1451ea <cygthread::stub(void*)>, arg=0x7ffe4a3355b8 <threads+88>, buf=buf@entry=0x2aecd50) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
#4  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
#5  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#6  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#7  0x0000000000000000 in ?? ()
(gdb) thread 4
[Switching to thread 4 (Thread 0x131c)]
#0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffe5794eb5e in ntdll!RtlReleaseSRWLockExclusive () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#2  0x00007ffe4a145e08 in _cygtls::call2 (this=0x323ce00, func=0x7ffe5794e3f0 <ntdll!RtlReleaseSRWLockExclusive+8704>, arg=0xc0b60, buf=buf@entry=0x323cd50) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
#3  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
#4  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#5  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#6  0x0000000000000000 in ?? ()
(gdb) thread 5
[Switching to thread 5 (Thread 0x9b8)]
#0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) bt
#0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#1  0x00007ffe5794eb5e in ntdll!RtlReleaseSRWLockExclusive () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#2  0x00007ffe4a145e08 in _cygtls::call2 (this=0x343ce00, func=0x7ffe5794e3f0 <ntdll!RtlReleaseSRWLockExclusive+8704>, arg=0xc0b60, buf=buf@entry=0x343cd50) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
#3  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
#4  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
#5  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
#6  0x0000000000000000 in ?? ()
(gdb) thread 6
Unknown thread 6.
(gdb) thread 1
[Switching to thread 1 (Thread 0x11cc)]
#0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
(gdb) up
#1  0x00007ffe54156d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
(gdb)
#2  0x00007ffe4a2033a0 in fhandler_console::close (this=0x800009030) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc:1914
1914    in /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc
(gdb) p thread_sync_event
$6 = (HANDLE) 0x1510
(gdb) p name
$7 = "cygcons.thread_sync.0", '\000' <repeats 19 times>, "r", '\000' <repeats 183 times>...
(gdb) p con.owner
No symbol "con" in current context.
(gdb) p master_thread_started
$8 = true
(gdb) p unit
$9 = 0
(gdb) p shared_console_info
$10 = {0x1a0030000, 0x0 <repeats 64 times>}
(gdb)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: cygwin application hangs on closing console
  2024-05-15 15:48         ` Johannes Khoshnazar-Thoma
@ 2024-05-15 20:24           ` Brian Inglis
  2024-05-16  9:14           ` Takashi Yano
  1 sibling, 0 replies; 8+ messages in thread
From: Brian Inglis @ 2024-05-15 20:24 UTC (permalink / raw)
  To: cygwin

On 2024-05-15 09:48, Johannes Khoshnazar-Thoma via Cygwin wrote:
> Hi again,
> 
> Am 15.05.24 um 17:37 schrieb Johannes Khoshnazar-Thoma:
>> Hi again,
>>
>> Am 23.04.24 um 12:26 schrieb Takashi Yano:
>>>>> Thanks for the report. Could you please test cygwin1.dll 3.5.3-1
>>>>> wihch is the latest cygwin release?
>>>>>
>>
>> We retried the tests with cygwin1.dll 3.5.3-1 and it looks like
>> the issue is still there. Here's an excerpt from the gdb debug
>> session:
>>
> Sorry somehow the formatting got messed up I try again:
> 
> (gdb) info thread
>    Id   Target Id         Frame
> * 1    Thread 0x11cc     0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () 
> from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
>    2    Thread 0x8ec      0x00007ffe579d5ee4 in ntdll!ZwReadFile () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
>    3    Thread 0x55c      0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () 
> from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
>    4    Thread 0x131c     0x00007ffe579d95f4 in 
> ntdll!ZwWaitForWorkViaWorkerFactory () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
>    5    Thread 0x9b8      0x00007ffe579d95f4 in 
> ntdll!ZwWaitForWorkViaWorkerFactory () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> (gdb) thread 1
> [Switching to thread 1 (Thread 0x11cc)]
> #0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> (gdb) bt
> #0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #1  0x00007ffe54156d1f in WaitForSingleObjectEx () from 
> C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
> #2  0x00007ffe4a2033a0 in fhandler_console::close (this=0x800009030) at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc:1914
> #3  0x00007ffe4a1f6ce7 in fhandler_base::close_with_arch (this=0x800009030) at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/base.cc:1288
> #4  0x00007ffe4a26a4cd in init_cygheap::close_ctty (this=0x800000000) at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/mm/cygheap.cc:135
> #5  0x00007ffe4a1c7c4e in close_all_files (norelease=norelease@entry=false) at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/syscalls.cc:81
> #6  0x00007ffe4a146840 in do_exit (status=0) at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1128
> #7  0x00007ffe4a1469f7 in _exit (n=<optimized out>) at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1243
> #8  0x00007ffe4a2a4bb9 in exit (code=0) at 
> /usr/src/debug/cygwin-3.5.3-1/newlib/libc/stdlib/exit.c:65
> #9  0x00007ffe4a1469e7 in cygwin_exit (n=5392) at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1237
> #10 0x00007ffe4a14809a in dll_crt0_1 () at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/dcrt0.cc:1002
> #11 0x00007ffe4a145e08 in _cygtls::call2 (this=0x7ffffce00, func=0x7ffe4a146fb8 
> <dll_crt0_1(void*)>, arg=0x0, buf=buf@entry=0x7ffffcdf0) at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
> #12 0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized 
> out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
> #13 0x0000000000000000 in ?? ()
> (gdb) thread 2
> [Switching to thread 2 (Thread 0x8ec)]
> #0  0x00007ffe579d5ee4 in ntdll!ZwReadFile () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> (gdb) bt
> #0  0x00007ffe579d5ee4 in ntdll!ZwReadFile () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #1  0x00007ffe5415e704 in ReadFile () from 
> C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
> #2  0x00007ffe4a1bada6 in wait_sig () at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/sigproc.cc:1324
> #3  0x00007ffe4a144d5f in cygthread::callfunc (this=this@entry=0x7ffe4a335560 
> <threads>, issimplestub=issimplestub@entry=false) at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygthread.cc:48
> #4  0x00007ffe4a145270 in cygthread::stub (arg=arg@entry=0x7ffe4a335560 
> <threads>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygthread.cc:91
> #5  0x00007ffe4a145e08 in _cygtls::call2 (this=0xdbce00, func=0x7ffe4a1451ea 
> <cygthread::stub(void*)>, arg=0x7ffe4a335560 <threads>, buf=buf@entry=0xdbcd50) 
> at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
> #6  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized 
> out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
> #7  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from 
> C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
> #8  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #9  0x0000000000000000 in ?? ()
> (gdb) thread 3
> [Switching to thread 3 (Thread 0x55c)]
> #0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> (gdb) bt
> #0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #1  0x00007ffe54156d1f in WaitForSingleObjectEx () from 
> C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
> #2  0x00007ffe4a1452ab in cygthread::stub (arg=arg@entry=0x7ffe4a3355b8 
> <threads+88>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygthread.cc:112
> #3  0x00007ffe4a145e08 in _cygtls::call2 (this=0x2aece00, func=0x7ffe4a1451ea 
> <cygthread::stub(void*)>, arg=0x7ffe4a3355b8 <threads+88>, 
> buf=buf@entry=0x2aecd50) at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
> #4  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized 
> out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
> #5  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from 
> C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
> #6  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #7  0x0000000000000000 in ?? ()
> (gdb) thread 4
> [Switching to thread 4 (Thread 0x131c)]
> #0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> (gdb) bt
> #0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #1  0x00007ffe5794eb5e in ntdll!RtlReleaseSRWLockExclusive () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #2  0x00007ffe4a145e08 in _cygtls::call2 (this=0x323ce00, func=0x7ffe5794e3f0 
> <ntdll!RtlReleaseSRWLockExclusive+8704>, arg=0xc0b60, buf=buf@entry=0x323cd50) 
> at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
> #3  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized 
> out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
> #4  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from 
> C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
> #5  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #6  0x0000000000000000 in ?? ()
> (gdb) thread 5
> [Switching to thread 5 (Thread 0x9b8)]
> #0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> (gdb) bt
> #0  0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #1  0x00007ffe5794eb5e in ntdll!RtlReleaseSRWLockExclusive () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #2  0x00007ffe4a145e08 in _cygtls::call2 (this=0x343ce00, func=0x7ffe5794e3f0 
> <ntdll!RtlReleaseSRWLockExclusive+8704>, arg=0xc0b60, buf=buf@entry=0x343cd50) 
> at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:41
> #3  0x00007ffe4a145e86 in _cygtls::call (func=<optimized out>, arg=<optimized 
> out>) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/cygtls.cc:28
> #4  0x00007ffe555584d4 in KERNEL32!BaseThreadInitThunk () from 
> C:\src\dlls-syms\kernel32.dll\640993B0ad000\kernel32.dll
> #5  0x00007ffe57981791 in ntdll!RtlUserThreadStart () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #6  0x0000000000000000 in ?? ()
> (gdb) thread 6
> Unknown thread 6.
> (gdb) thread 1
> [Switching to thread 1 (Thread 0x11cc)]
> #0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from 
> C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> (gdb) up
> #1  0x00007ffe54156d1f in WaitForSingleObjectEx () from 
> C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
> (gdb)
> #2  0x00007ffe4a2033a0 in fhandler_console::close (this=0x800009030) at 
> /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc:1914
> 1914    in /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc
> (gdb) p thread_sync_event
> $6 = (HANDLE) 0x1510
> (gdb) p name
> $7 = "cygcons.thread_sync.0", '\000' <repeats 19 times>, "r", '\000' <repeats 
> 183 times>...
> (gdb) p con.owner
> No symbol "con" in current context.
> (gdb) p master_thread_started
> $8 = true
> (gdb) p unit
> $9 = 0
> (gdb) p shared_console_info
> $10 = {0x1a0030000, 0x0 <repeats 64 times>}
> (gdb)

Sometimes a Cygwin strace can be helpful, for example:

	$ strace -o drbdadm.strace drbdadm <ARGS>

or equivalent however you execute the program.

Attach the strace output as text if possible, otherwise if too big, xz, bz2, lz, 
zstd, gz.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: cygwin application hangs on closing console
  2024-05-15 15:48         ` Johannes Khoshnazar-Thoma
  2024-05-15 20:24           ` Brian Inglis
@ 2024-05-16  9:14           ` Takashi Yano
  1 sibling, 0 replies; 8+ messages in thread
From: Takashi Yano @ 2024-05-16  9:14 UTC (permalink / raw)
  To: cygwin; +Cc: Johannes Khoshnazar-Thoma

On Wed, 15 May 2024 17:48:49 +0200
Johannes Khoshnazar-Thoma wrote:
> Hi again,
> 
> Am 15.05.24 um 17:37 schrieb Johannes Khoshnazar-Thoma:
> > Hi again,
> >
> > Am 23.04.24 um 12:26 schrieb Takashi Yano:
> >>>> Thanks for the report. Could you please test cygwin1.dll 3.5.3-1
> >>>> wihch is the latest cygwin release?
> >>>>
> >
> > We retried the tests with cygwin1.dll 3.5.3-1 and it looks like
> > the issue is still there. Here's an excerpt from the gdb debug
> > session:
> >
> Sorry somehow the formatting got messed up I try again:

Thanks for testing and the additional information.

> (gdb) info thread
>    Id   Target Id         Frame
> * 1    Thread 0x11cc     0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
>    2    Thread 0x8ec      0x00007ffe579d5ee4 in ntdll!ZwReadFile () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
>    3    Thread 0x55c      0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
>    4    Thread 0x131c     0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
>    5    Thread 0x9b8      0x00007ffe579d95f4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> (gdb) thread 1
> [Switching to thread 1 (Thread 0x11cc)]
> #0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> (gdb) bt
> #0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> #1  0x00007ffe54156d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
> #2  0x00007ffe4a2033a0 in fhandler_console::close (this=0x800009030) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc:1914

Line 1914 of fhandler/console.cc is:
      WaitForSingleObject (thread_sync_event, INFINITE);

This waits termination of cons_master_thread(). However, it does not seem
that the cons_master_thread exists in thread list obove. If the thread was
terminated normally, thread_sync_event should has been set.

> #0  0x00007ffe579d5ea4 in ntdll!ZwWaitForSingleObject () from C:\src\dlls-syms\ntdll.dll\6502806A1cf000\ntdll.dll
> (gdb) up
> #1  0x00007ffe54156d1f in WaitForSingleObjectEx () from C:\src\dlls-syms\KERNELBASE.dll\660F5EEC21e000\KERNELBASE.dll
> (gdb)
> #2  0x00007ffe4a2033a0 in fhandler_console::close (this=0x800009030) at /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc:1914
> 1914    in /usr/src/debug/cygwin-3.5.3-1/winsup/cygwin/fhandler/console.cc
> (gdb) p thread_sync_event
> $6 = (HANDLE) 0x1510
> (gdb) p name
> $7 = "cygcons.thread_sync.0", '\000' <repeats 19 times>, "r", '\000' <repeats 183 times>...
> (gdb) p con.owner
> No symbol "con" in current context.
> (gdb) p master_thread_started
> $8 = true
> (gdb) p unit
> $9 = 0
> (gdb) p shared_console_info
> $10 = {0x1a0030000, 0x0 <repeats 64 times>}
> (gdb)

fhandler_console::close() was called twice? Or master thread had crashed
without setting thread_sync_event?

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-05-16  9:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-22 12:50 cygwin application hangs on closing console 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-16  9:14           ` Takashi Yano

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).