public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Non-Cygwin programs touching a pipe's read side makes the write side unselectable
@ 2024-03-10  5:49 wh
  2024-03-10  8:38 ` Takashi Yano
  0 siblings, 1 reply; 3+ messages in thread
From: wh @ 2024-03-10  5:49 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 2609 bytes --]

Here's how to reproduce this behavior.

In test3.pl:

#!/usr/bin/perl
my $wfds = '';
vec($wfds, fileno(STDOUT), 1) = 1;
sleep 1;
print STDERR "selecting\n";
select undef, $wfds, undef, undef;
print STDERR "ready\n";
print "abc\n";

Then run:

# curl is as shipped with Windows, /cygdrive/c/Windows/system32/curl
./test3.pl | (curl --version && cat)

Expected result:

curl 8.4.0 (Windows) libcurl/8.4.0 Schannel WinIDN
...
selecting
ready
abc

Actual result:

curl 8.4.0 (Windows) libcurl/8.4.0 Schannel WinIDN
...
selecting
(hang)

Using strace on perl, it ends with

   95  332358 [main] perl 733 clock_nanosleep: clock_nanosleep (1.000000000)
1004437 1336795 [main] perl 733 clock_nanosleep: 0 = clock_nanosleep(1, 0, 1.000000000, 0.d)
  247 1337042 [main] perl 733 time: 1710048216 = time(0x7FFFFCA00)
 1010 1338052 [main] perl 733 fhandler_console::write: 0xA00051B10, 10
  822 1338874 [main] perl 733 fhandler_console::write: 10 = fhandler_console::write(...)
  203 1339077 [main] perl 733 write: 10 = write(2, 0xA00051B10, 10)
  254 1339331 [main] perl 733 pselect: pselect (8, 0x0, 0xA000330E0, 0x0, 0x0, 0x0)
  207 1339538 [main] perl 733 pselect: to NULL, us -1
  490 1340028 [main] perl 733 dtable::select_write:  fd 1
  191 1340219 [main] perl 733 select: sel.always_ready 0
--- Process 6888 (pid: 733) thread 784 created
  859 1341078 [pipesel] perl 733 cygthread::stub: thread 'pipesel', id 0x310, stack_ptr 0x2BBCCB0
  192 1341270 [main] perl 733 select_stuff::wait: m 3, us 18446744073709551615, wmfo_timeout -1
  196 1341466 [pipesel] perl 733 SetThreadName: SetThreadDescription() failed. 00000000 10000000

Pipesel never comes back.

Other info:

- Replacing cat with tee (tee with no args is the same as cat) makes it work. tee reads in smaller chunks, while cat reads at the pipe buffer size. Comments in select.cc suggest this is important, but I don't understand it all.
- Removing the curl makes it work
- Using curl </dev/null to make curl not touch stdin makes it work
- Using a Cygwin program instead of a non-Cygwin program e.g. id instead of curl makes it work
- Removing the select confirms that nothing weird is breaking the pipe, and the "abc' shows up properly

There was a report in MSYS2 https://github.com/msys2/msys2-runtime/issues/202 also about pipes to external programs, but there are some differences. In this scenario the non-Cygwin curl doesn't actually read anything from the pipe, and it should have exited before the select call. I tried a build of MSYS2 with their fix, and it still hangs in this way.

[-- Attachment #2: cygcheck.out --]
[-- Type: application/octet-stream, Size: 25821 bytes --]


Cygwin Configuration Diagnostics
Current System Time: Sun Mar 10 06:28:22 2024

Windows 10 Home Ver 10.0 Build 19045 

Path:	C:\Users\wh0\Downloads\delete-whenever\cygwin\usr\local\bin
	C:\Users\wh0\Downloads\delete-whenever\cygwin\bin
	C:\Windows\system32
	C:\Windows
	C:\Windows\System32\Wbem
	C:\Windows\System32\WindowsPowerShell\v1.0
	C:\Windows\System32\OpenSSH
	C:\Users\wh0\AppData\Local\Microsoft\WindowsApps

Output from C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\id.exe
UID: 197609(wh0)               GID: 197121(None)
197121(None)                   545(Users)
4(INTERACTIVE)                 66049(CONSOLE LOGON)
11(Authenticated Users)        15(This Organization)
113(Local account)             4095(CurrentSession)
66048(LOCAL)                   262154(NTLM Authentication)
401408(Medium Mandatory Level)

SysDir: C:\Windows\system32
WinDir: C:\Windows

PWD = '/home/wh0'
HOME = '/home/wh0'
USER = 'wh0'

ProgramFiles(x86) = 'C:\Program Files (x86)'
!:: = '::\'
CommonProgramFiles(x86) = 'C:\Program Files (x86)\Common Files'
SHELL = '/bin/bash'
NUMBER_OF_PROCESSORS = '2'
FPS_BROWSER_USER_PROFILE_STRING = 'Default'
PROCESSOR_LEVEL = '6'
TERM_PROGRAM_VERSION = '3.7.1'
USERDOMAIN_ROAMINGPROFILE = 'VACATION'
HOSTNAME = 'vacation'
PROGRAMFILES = 'C:\Program Files'
PATHEXT = '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
OS = 'Windows_NT'
HOMEDRIVE = 'C:'
USERDOMAIN = 'VACATION'
USERPROFILE = 'C:\Users\wh0'
PRINTER = 'Microsoft Print to PDF'
TZ = 'America/Los_Angeles'
ALLUSERSPROFILE = 'C:\ProgramData'
ORIGINAL_PATH = '/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Windows/System32/OpenSSH:/cygdrive/c/Users/wh0/AppData/Local/Microsoft/WindowsApps'
CommonProgramW6432 = 'C:\Program Files\Common Files'
USERNAME = 'wh0'
OneDrive = 'C:\Users\wh0\OneDrive'
COMSPEC = 'C:\Windows\system32\cmd.exe'
APPDATA = 'C:\Users\wh0\AppData\Roaming'
SYSTEMROOT = 'C:\Windows'
LOCALAPPDATA = 'C:\Users\wh0\AppData\Local'
__COMPAT_LAYER = 'DetectorsAppHealth'
COMPUTERNAME = 'VACATION'
INFOPATH = '/usr/local/info:/usr/share/info:/usr/info'
TERM = 'xterm'
LOGONSERVER = '\\VACATION'
PSModulePath = 'C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules'
TEMP = '/tmp'
SHLVL = '1'
PROCESSOR_REVISION = '3a09'
DriverData = 'C:\Windows\System32\Drivers\DriverData'
COMMONPROGRAMFILES = 'C:\Program Files\Common Files'
LC_CTYPE = 'en_US.UTF-8'
PROCESSOR_IDENTIFIER = 'Intel64 Family 6 Model 58 Stepping 9, GenuineIntel'
SESSIONNAME = 'Console'
PS1 = '\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
HOMEPATH = '\Users\wh0'
TMP = '/tmp'
ProgramW6432 = 'C:\Program Files'
PROFILEREAD = 'true'
MINTTY_SHORTCUT = '/cygdrive/c/Users/wh0/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Cygwin/Cygwin64 Terminal.lnk'
WINDIR = 'C:\Windows'
FPS_BROWSER_APP_PROFILE_STRING = 'Internet Explorer'
PROCESSOR_ARCHITECTURE = 'AMD64'
PUBLIC = 'C:\Users\Public'
SYSTEMDRIVE = 'C:'
EXECIGNORE = '*.dll'
OLDPWD = '/home/wh0'
TERM_PROGRAM = 'mintty'
ProgramData = 'C:\ProgramData'
_ = '/usr/bin/cygcheck'

HKEY_CURRENT_USER\SOFTWARE\Cygwin
HKEY_CURRENT_USER\SOFTWARE\Cygwin\Installations
  (default) = '\??\C:\Users\wh0\Downloads\delete-whenever\cygwin'
HKEY_CURRENT_USER\SOFTWARE\Cygwin\setup
  (default) = 'C:\Users\wh0\Downloads\delete-whenever\cygwin'
HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin
HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin\Installations
  (default) = '\??\C:\Users\wh0\Downloads\delete-whenever\cygwin'

obcaseinsensitive set to 1

Cygwin installations found in the registry:
  System: Key: 5636d8e09821303f Path: C:\Users\wh0\Downloads\delete-whenever\cygwin
  User:   Key: 5636d8e09821303f Path: C:\Users\wh0\Downloads\delete-whenever\cygwin

c:  hd  NTFS    476312Mb  27% CP CS UN PA FC    QU  
e:  cd             N/A    N/A                       

C:\Users\wh0\Downloads\delete-whenever\cygwin      /          system  binary,auto
C:\Users\wh0\Downloads\delete-whenever\cygwin\bin  /usr/bin   system  binary,auto
C:\Users\wh0\Downloads\delete-whenever\cygwin\lib  /usr/lib   system  binary,auto
cygdrive prefix                                    /cygdrive  user    binary,posix=0,auto

Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\awk
 -> C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\gawk.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\bash.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cat.exe
Found: C:\Windows\system32\certutil.exe
Not Found: clinfo
Found: C:\Windows\system32\comp.exe
Found: C:\Windows\system32\convert.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cp.exe
Not Found: cpp (good!)
Not Found: crontab
Found: C:\Windows\system32\curl.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\expand.exe
Found: C:\Windows\system32\expand.exe
Warning: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\expand.exe hides C:\Windows\system32\expand.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\find.exe
Found: C:\Windows\system32\find.exe
Warning: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\find.exe hides C:\Windows\system32\find.exe
Found: C:\Windows\system32\ftp.exe
Not Found: gcc
Not Found: gdb
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\grep.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\hostname.exe
Found: C:\Windows\system32\hostname.exe
Warning: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\hostname.exe hides C:\Windows\system32\hostname.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\kill.exe
Found: C:\Windows\system32\klist.exe
Not Found: ld
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\ls.exe
Not Found: make
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\mv.exe
Found: C:\Windows\system32\nslookup.exe
Not Found: patch
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\perl.exe
Found: C:\Windows\system32\replace.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\rm.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\sed.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\sh.exe
Found: C:\Windows\system32\shutdown.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\sort.exe
Found: C:\Windows\system32\sort.exe
Warning: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\sort.exe hides C:\Windows\system32\sort.exe
Found: C:\Windows\System32\OpenSSH\ssh.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\tar.exe
Found: C:\Windows\system32\tar.exe
Warning: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\tar.exe hides C:\Windows\system32\tar.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\test.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\timeout.exe
Found: C:\Windows\system32\timeout.exe
Warning: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\timeout.exe hides C:\Windows\system32\timeout.exe
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\vi.exe
Not Found: vim
Found: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\whoami.exe
Found: C:\Windows\system32\whoami.exe
Warning: C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\whoami.exe hides C:\Windows\system32\whoami.exe

   45k 2023/07/11 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygargp-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygargp-0.dll" v0.0 ts=2023-07-11 20:11
   17k 2023/01/15 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygattr-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygattr-1.dll" v0.0 ts=2023-01-15 15:39
  250k 2024/01/24 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygblkid-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygblkid-1.dll" v0.0 ts=2024-01-24 08:22
  134k 2023/12/12 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygbrotlicommon-1.dll - os=4.0 img=1.1 sys=5.2
                  "cygbrotlicommon-1.dll" v0.0 ts=2023-12-12 12:18
   49k 2023/12/12 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygbrotlidec-1.dll - os=4.0 img=1.1 sys=5.2
                  "cygbrotlidec-1.dll" v0.0 ts=2023-12-12 12:18
   66k 2019/07/21 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygbz2-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygbz2-1.dll" v0.0 ts=2019-07-22 00:05
   13k 2019/01/02 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygcom_err-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygcom_err-2.dll" v0.0 ts=2019-01-02 02:39
  193k 2021/05/20 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygcrypt-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygcrypt-2.dll" v0.0 ts=2021-05-20 09:38
 2487k 2023/09/12 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygcrypto-1.1.dll - os=4.0 img=0.0 sys=5.2
                  "cygcrypto-1.1.dll" v0.0 ts=2023-09-12 18:36
 3760k 2024/02/03 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygcrypto-3.dll - os=4.0 img=0.0 sys=5.2
                  "cygcrypto-3.dll" v0.0 ts=2024-02-03 15:51
  678k 2024/02/03 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygcurl-4.dll - os=4.0 img=0.0 sys=5.2
                  "cygcurl-4.dll" v0.0 ts=2024-02-03 22:22
 1552k 2017/09/28 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygdb-5.3.dll - os=4.0 img=0.0 sys=5.2
                  "cygdb-5.3.dll" v0.0 ts=2017-09-28 20:05
  119k 2017/09/28 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygdb_cxx-5.3.dll - os=4.0 img=0.0 sys=5.2
                  "cygdb_cxx-5.3.dll" v0.0 ts=2017-09-28 20:06
  569k 2017/09/28 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygdb_sql-5.3.dll - os=4.0 img=0.0 sys=5.2
                  "cygdb_sql-5.3.dll" v0.0 ts=2017-09-28 20:06
  354k 2024/01/24 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygfdisk-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygfdisk-1.dll" v0.0 ts=2024-01-24 08:22
   27k 2015/11/17 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygffi-6.dll - os=4.0 img=0.0 sys=5.2
                  "cygffi-6.dll" v0.0 ts=2015-11-17 22:14
   60k 2024/01/21 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygformw-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygformw-10.dll" v0.0 ts=2024-01-21 04:35
   74k 2023/06/05 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyggcc_s-seh-1.dll - os=4.0 img=0.0 sys=5.2
                  "cyggcc_s-seh-1.dll" v0.0 ts=2023-06-05 16:00
  820k 2023/11/19 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyggcrypt-20.dll - os=4.0 img=0.0 sys=5.2
                  "cyggcrypt-20.dll" v0.0 ts=2023-11-19 19:27
   49k 2019/07/10 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyggdbm-6.dll - os=4.0 img=0.0 sys=5.2
                  "cyggdbm-6.dll" v0.0 ts=2019-07-10 14:53
   13k 2019/07/10 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyggdbm_compat-4.dll - os=4.0 img=0.0 sys=5.2
                  "cyggdbm_compat-4.dll" v0.0 ts=2019-07-10 14:53
  591k 2023/07/31 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyggmp-10.dll - os=4.0 img=0.0 sys=5.2
                  "cyggmp-10.dll" v0.0 ts=2023-07-31 20:20
  116k 2020/02/16 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyggpg-error-0.dll - os=4.0 img=0.0 sys=5.2
                  "cyggpg-error-0.dll" v0.0 ts=2020-02-16 21:28
  113k 2024/01/06 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyggsasl-18.dll - os=4.0 img=0.0 sys=5.2
                  "cyggsasl-18.dll" v0.0 ts=2024-01-06 22:09
  274k 2018/03/16 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyggssapi_krb5-2.dll - os=4.0 img=0.0 sys=5.2
                  "cyggssapi_krb5-2.dll" v0.0 ts=2018-03-16 03:38
   36k 2022/10/08 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyghistory7.dll - os=4.0 img=0.0 sys=5.2
                  "cyghistory7.dll" v0.0 ts=2022-10-08 05:37
 1063k 2022/05/23 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygiconv-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygiconv-2.dll" v0.0 ts=2022-05-23 12:22
  198k 2024/01/14 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygidn-12.dll - os=4.0 img=0.0 sys=5.2
                  "cygidn-12.dll" v0.0 ts=2024-01-14 07:47
  339k 2024/01/28 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygidn2-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygidn2-0.dll" v0.0 ts=2024-01-28 01:14
  105k 2023/11/25 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygintl-8.dll - os=4.0 img=0.0 sys=5.2
                  "cygintl-8.dll" v0.0 ts=2023-11-25 22:21
  192k 2018/03/16 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygk5crypto-3.dll - os=4.0 img=0.0 sys=5.2
                  "cygk5crypto-3.dll" v0.0 ts=2018-03-16 03:37
  754k 2018/03/16 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygkrb5-3.dll - os=4.0 img=0.0 sys=5.2
                  "cygkrb5-3.dll" v0.0 ts=2018-03-16 03:37
   37k 2018/03/16 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygkrb5support-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygkrb5support-0.dll" v0.0 ts=2018-03-16 03:36
   48k 2024/02/11 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyglber-2-4-2.dll - os=4.0 img=0.0 sys=5.2
                  "cyglber-2.dll" v0.0 ts=2024-02-11 12:25
   48k 2024/02/11 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyglber-2.dll - os=4.0 img=0.0 sys=5.2
                  "cyglber-2.dll" v0.0 ts=2024-02-11 12:25
  323k 2024/02/11 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygldap-2-4-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygldap-2.dll" v0.0 ts=2024-02-11 12:26
  323k 2024/02/11 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygldap-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygldap-2.dll" v0.0 ts=2024-02-11 12:26
  323k 2024/02/11 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygldap_r-2-4-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygldap-2.dll" v0.0 ts=2024-02-11 12:26
  136k 2022/10/30 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyglz4-1.dll - os=4.0 img=0.0 sys=5.2
                  "cyglz4-1.dll" v0.0 ts=2022-10-30 17:59
  175k 2024/02/25 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyglzma-5.dll - os=4.0 img=0.0 sys=5.2
                  "cyglzma-5.dll" v0.0 ts=2024-02-25 10:06
  160k 2023/01/14 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygmagic-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygmagic-1.dll" v0.0 ts=2023-01-14 21:35
  214k 2023/09/24 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygman-2-12-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygman-2-12-0.dll" v0.0 ts=2023-09-24 19:20
   25k 2023/09/24 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygmandb-2-12-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygmandb-2-12-0.dll" v0.0 ts=2023-09-24 19:20
   29k 2024/01/21 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygmenuw-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygmenuw-10.dll" v0.0 ts=2024-01-21 04:34
  650k 2023/08/22 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygmpfr-6.dll - os=4.0 img=0.0 sys=5.2
                  "cygmpfr-6.dll" v0.0 ts=2023-08-22 18:46
  337k 2024/01/21 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygncursesw-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygncursesw-10.dll" v0.0 ts=2024-01-21 04:32
  174k 2024/03/03 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygnghttp2-14.dll - os=4.0 img=0.0 sys=5.2
                  "cygnghttp2-14.dll" v0.0 ts=2024-03-03 16:29
   30k 2015/03/19 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygntlm-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygntlm-0.dll" v0.0 ts=2015-03-19 02:15
 1020k 2020/03/27 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygp11-kit-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygp11-kit-0.dll" v0.0 ts=2020-03-27 22:30
   13k 2024/01/21 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygpanelw-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygpanelw-10.dll" v0.0 ts=2024-01-21 04:34
  497k 2021/06/20 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygpcre-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygpcre-1.dll" v0.0 ts=2021-06-20 12:53
  637k 2024/02/18 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygpcre2-8-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygpcre2-8-0.dll" v0.0 ts=2024-02-18 09:01
 3710k 2023/11/30 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygperl5_36.dll - os=4.0 img=0.0 sys=5.2
                  "cygperl5_36.dll" v0.0 ts=2023-11-30 20:40
   44k 2022/10/06 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygpipeline-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygpipeline-1.dll" v0.0 ts=2022-10-06 19:49
   42k 2023/02/19 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygpopt-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygpopt-0.dll" v0.0 ts=2023-02-19 19:45
   69k 2024/01/14 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygpsl-5.dll - os=4.0 img=0.0 sys=5.2
                  "cygpsl-5.dll" v0.0 ts=2024-01-14 00:44
  257k 2022/10/08 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygreadline7.dll - os=4.0 img=0.0 sys=5.2
                  "cygreadline7.dll" v0.0 ts=2022-10-08 05:37
   99k 2020/01/09 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygsasl2-3.dll - os=4.0 img=0.0 sys=5.2
                  "cygsasl2-3.dll" v0.0 ts=2020-01-09 02:13
  157k 2024/01/24 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygsmartcols-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygsmartcols-1.dll" v0.0 ts=2024-01-24 08:22
  248k 2023/06/04 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygssh2-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygssh2-1.dll" v0.0 ts=2023-06-04 07:30
  512k 2023/09/12 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygssl-1.1.dll - os=4.0 img=0.0 sys=5.2
                  "cygssl-1.1.dll" v0.0 ts=2023-09-12 18:36
  591k 2024/02/03 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygssl-3.dll - os=4.0 img=0.0 sys=5.2
                  "cygssl-3.dll" v0.0 ts=2024-02-03 15:51
 1904k 2023/06/05 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygstdc++-6.dll - os=4.0 img=0.0 sys=5.2
                  "cygstdc++-6.dll" v0.0 ts=2023-06-05 16:06
   68k 2019/07/29 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygtasn1-6.dll - os=4.0 img=0.0 sys=5.2
                  "cygtasn1-6.dll" v0.0 ts=2019-07-29 03:12
   59k 2024/01/21 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygticw-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygticw-10.dll" v0.0 ts=2024-01-21 04:33
  185k 2023/07/16 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyguchardet-0.dll - os=4.0 img=0.0 sys=5.2
                  "cyguchardet-0.dll" v0.0 ts=2023-07-16 08:19
 1784k 2022/10/27 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygunistring-5.dll - os=4.0 img=0.0 sys=5.2
                  "cygunistring-5.dll" v0.0 ts=2022-10-27 17:07
   27k 2024/01/24 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cyguuid-1.dll - os=4.0 img=0.0 sys=5.2
                  "cyguuid-1.dll" v0.0 ts=2024-01-24 08:20
   88k 2024/01/27 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygz.dll - os=4.0 img=0.0 sys=5.2
                  "cygz.dll" v0.0 ts=2024-01-27 09:12
  650k 2023/04/12 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygzstd-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygzstd-1.dll" v0.0 ts=2023-04-12 16:04
 2941k 2024/02/27 C:\Users\wh0\Downloads\delete-whenever\cygwin\bin\cygwin1.dll - os=4.0 img=0.0 sys=5.2
                  "cygwin1.dll" v0.0 ts=2024-02-27 11:56
    Cygwin DLL version info:
        DLL version: 3.5.1
        API major: 0
        API minor: 350
        Shared data: 5
        DLL identifier: cygwin1
        Mount registry: 3
        Cygwin registry name: Cygwin
        Installations name: Installations
        Cygdrive default prefix: 
        Build date: 
        Shared id: cygwin1S5


Can't find the cygrunsrv utility, skipping services check.


Cygwin Package Information
Last downloaded files to: C:\Users\wh0\Downloads\delete-whenever\cygwin
Last downloaded files from: https://mirrors.sonic.net/cygwin/

Package                 Version                 	Status
_autorebase             001091-1                     OK
alternatives            1.26-1                       OK
base-cygwin             3.8-2                        OK
base-files              4.3-3                        OK
bash                    5.2.21-1                     OK
bzip2                   1.0.8-1                      OK
ca-certificates         2023.2.62_v7.0.401-2         OK
coreutils               9.0-1                        OK
crypto-policies         20190218-1                   OK
cygutils                1.4.17-1                     OK
cygwin                  3.5.1-1                      OK
dash                    0.5.12-5                     OK
diffutils               3.10-1                       OK
editrights              1.04-1                       OK
file                    5.44-1                       OK
findutils               4.9.0-1                      OK
gawk                    5.3.0-1                      OK
getent                  2.18.90-5                    OK
grep                    3.11-1                       OK
groff                   1.23.0-1                     OK
gzip                    1.13-1                       OK
hostname                3.13-1                       OK
info                    7.1-1                        OK
ipc-utils               1.1-1                        OK
less                    643-1                        OK
libargp                 20230708-2                   OK
libattr1                2.5.1-1.20.g0981a7bfe487     OK
libblkid1               2.33.1-3                     OK
libbrotlicommon1        1.1.0-1                      OK
libbrotlidec1           1.1.0-1                      OK
libbz2_1                1.0.8-1                      OK
libcom_err2             1.44.5-1                     OK
libcrypt2               4.4.20-1                     OK
libcurl4                8.6.0-1                      OK
libdb5.3                5.3.28-2                     OK
libfdisk1               2.33.1-3                     OK
libffi6                 3.2.1-2                      OK
libgcc1                 11.4.0-1                     OK
libgcrypt20             1.10.3-1                     OK
libgdbm6                1.18.1-1                     OK
libgdbm_compat4         1.18.1-1                     OK
libgmp10                6.3.0-1                      OK
libgpg-error0           1.37-1                       OK
libgsasl-common         2.2.1-1                      OK
libgsasl18              2.2.1-1                      OK
libgssapi_krb5_2        1.15.2-2                     OK
libiconv2               1.17-1                       OK
libidn12                1.42-1                       OK
libidn2_0               2.3.7-1                      OK
libintl8                0.22.4-1                     OK
libk5crypto3            1.15.2-2                     OK
libkrb5_3               1.15.2-2                     OK
libkrb5support0         1.15.2-2                     OK
liblz4_1                1.9.4-1                      OK
liblzma5                5.6.0-1                      OK
libmpfr6                4.2.1-1                      OK
libncursesw10           6.4-20240120                 OK
libnghttp2_14           1.60.0-1                     OK
libntlm0                1.4-1                        OK
libopenldap2            2.6.7-1                      OK
libopenldap2_4_2        2.6.7-1                      OK
libp11-kit0             0.23.20-1                    OK
libpcre1                8.45-1                       OK
libpcre2_8_0            10.43-1                      OK
libpipeline1            1.5.6-1                      OK
libpopt-common          1.19-1                       OK
libpopt0                1.19-1                       OK
libpsl5                 0.21.5-1                     OK
libreadline7            8.2-2                        OK
libsasl2_3              2.1.27-1                     OK
libsmartcols1           2.33.1-3                     OK
libssh2_1               1.11.0-1                     OK
libssl1.1               1.1.1w-1                     OK
libssl3                 3.0.13-1                     OK
libstdc++6              11.4.0-1                     OK
libtasn1_6              4.14-1                       OK
libuchardet0            0.0.8-1                      OK
libunistring5           1.1-1                        OK
libuuid1                2.33.1-3                     OK
libzstd1                1.5.5-1                      OK
login                   1.13-1                       OK
man-db                  2.12.0-1                     OK
mintty                  3.7.1-1                      OK
ncurses                 6.4-20240120                 OK
openssl                 3.0.13-1                     OK
p11-kit                 0.23.20-1                    OK
p11-kit-trust           0.23.20-1                    OK
perl                    5.36.3-1                     OK
perl-JSON-PP            4.16-2                       OK
perl_autorebase         5.36.3-1                     OK
perl_base               5.36.3-1                     OK
publicsuffix-list-dafsa 20231213-1                   OK
rebase                  4.6.6-1                      OK
run                     1.3.4-2                      OK
sed                     4.9-1                        OK
tar                     1.35-2                       OK
terminfo                6.4-20240120                 OK
tzcode                  2024a-1                      OK
tzdata                  2024a-1                      OK
util-linux              2.33.1-3                     OK
vim-minimal             9.0.2155-2                   OK
which                   2.20-2                       OK
xz                      5.6.0-1                      OK
zlib0                   1.3.1-1                      OK
zstd                    1.5.5-1                      OK
Use -h to see help about each section

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

* Re: Non-Cygwin programs touching a pipe's read side makes the write side unselectable
  2024-03-10  5:49 Non-Cygwin programs touching a pipe's read side makes the write side unselectable wh
@ 2024-03-10  8:38 ` Takashi Yano
  2024-03-10 10:34   ` Takashi Yano
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Yano @ 2024-03-10  8:38 UTC (permalink / raw)
  To: cygwin; +Cc: wh

On Sun, 10 Mar 2024 05:49:43 +0000
wh wrote:
> Here's how to reproduce this behavior.
> 
> In test3.pl:
> 
> #!/usr/bin/perl
> my $wfds = '';
> vec($wfds, fileno(STDOUT), 1) = 1;
> sleep 1;
> print STDERR "selecting\n";
> select undef, $wfds, undef, undef;
> print STDERR "ready\n";
> print "abc\n";
> 
> Then run:
> 
> # curl is as shipped with Windows, /cygdrive/c/Windows/system32/curl
> ./test3.pl | (curl --version && cat)
> 
> Expected result:
> 
> curl 8.4.0 (Windows) libcurl/8.4.0 Schannel WinIDN
> ...
> selecting
> ready
> abc
> 
> Actual result:
> 
> curl 8.4.0 (Windows) libcurl/8.4.0 Schannel WinIDN
> ...
> selecting
> (hang)
> 
> Using strace on perl, it ends with
> 
>    95  332358 [main] perl 733 clock_nanosleep: clock_nanosleep (1.000000000)
> 1004437 1336795 [main] perl 733 clock_nanosleep: 0 = clock_nanosleep(1, 0, 1.000000000, 0.d)
>   247 1337042 [main] perl 733 time: 1710048216 = time(0x7FFFFCA00)
>  1010 1338052 [main] perl 733 fhandler_console::write: 0xA00051B10, 10
>   822 1338874 [main] perl 733 fhandler_console::write: 10 = fhandler_console::write(...)
>   203 1339077 [main] perl 733 write: 10 = write(2, 0xA00051B10, 10)
>   254 1339331 [main] perl 733 pselect: pselect (8, 0x0, 0xA000330E0, 0x0, 0x0, 0x0)
>   207 1339538 [main] perl 733 pselect: to NULL, us -1
>   490 1340028 [main] perl 733 dtable::select_write:  fd 1
>   191 1340219 [main] perl 733 select: sel.always_ready 0
> --- Process 6888 (pid: 733) thread 784 created
>   859 1341078 [pipesel] perl 733 cygthread::stub: thread 'pipesel', id 0x310, stack_ptr 0x2BBCCB0
>   192 1341270 [main] perl 733 select_stuff::wait: m 3, us 18446744073709551615, wmfo_timeout -1
>   196 1341466 [pipesel] perl 733 SetThreadName: SetThreadDescription() failed. 00000000 10000000
> 
> Pipesel never comes back.
> 
> Other info:
> 
> - Replacing cat with tee (tee with no args is the same as cat) makes it work. tee reads in smaller chunks, while cat reads at the pipe buffer size. Comments in select.cc suggest this is important, but I don't understand it all.
> - Removing the curl makes it work
> - Using curl </dev/null to make curl not touch stdin makes it work
> - Using a Cygwin program instead of a non-Cygwin program e.g. id instead of curl makes it work
> - Removing the select confirms that nothing weird is breaking the pipe, and the "abc' shows up properly
> 
> There was a report in MSYS2 https://github.com/msys2/msys2-runtime/issues/202 also about pipes to external programs, but there are some differences. In this scenario the non-Cygwin curl doesn't actually read anything from the pipe, and it should have exited before the select call. I tried a build of MSYS2 with their fix, and it still hangs in this way.

Thanks for the report. I looked into this problem, and found the cause.
Let me consider how to fix that.

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

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

* Re: Non-Cygwin programs touching a pipe's read side makes the write side unselectable
  2024-03-10  8:38 ` Takashi Yano
@ 2024-03-10 10:34   ` Takashi Yano
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Yano @ 2024-03-10 10:34 UTC (permalink / raw)
  To: cygwin

On Sun, 10 Mar 2024 17:38:53 +0900
Takashi Yano wrote:
> On Sun, 10 Mar 2024 05:49:43 +0000
> wh wrote:
> > Here's how to reproduce this behavior.
> > 
> > In test3.pl:
> > 
> > #!/usr/bin/perl
> > my $wfds = '';
> > vec($wfds, fileno(STDOUT), 1) = 1;
> > sleep 1;
> > print STDERR "selecting\n";
> > select undef, $wfds, undef, undef;
> > print STDERR "ready\n";
> > print "abc\n";
> > 
> > Then run:
> > 
> > # curl is as shipped with Windows, /cygdrive/c/Windows/system32/curl
> > ./test3.pl | (curl --version && cat)
> > 
> > Expected result:
> > 
> > curl 8.4.0 (Windows) libcurl/8.4.0 Schannel WinIDN
> > ...
> > selecting
> > ready
> > abc
> > 
> > Actual result:
> > 
> > curl 8.4.0 (Windows) libcurl/8.4.0 Schannel WinIDN
> > ...
> > selecting
> > (hang)
> > 
> > Using strace on perl, it ends with
> > 
> >    95  332358 [main] perl 733 clock_nanosleep: clock_nanosleep (1.000000000)
> > 1004437 1336795 [main] perl 733 clock_nanosleep: 0 = clock_nanosleep(1, 0, 1.000000000, 0.d)
> >   247 1337042 [main] perl 733 time: 1710048216 = time(0x7FFFFCA00)
> >  1010 1338052 [main] perl 733 fhandler_console::write: 0xA00051B10, 10
> >   822 1338874 [main] perl 733 fhandler_console::write: 10 = fhandler_console::write(...)
> >   203 1339077 [main] perl 733 write: 10 = write(2, 0xA00051B10, 10)
> >   254 1339331 [main] perl 733 pselect: pselect (8, 0x0, 0xA000330E0, 0x0, 0x0, 0x0)
> >   207 1339538 [main] perl 733 pselect: to NULL, us -1
> >   490 1340028 [main] perl 733 dtable::select_write:  fd 1
> >   191 1340219 [main] perl 733 select: sel.always_ready 0
> > --- Process 6888 (pid: 733) thread 784 created
> >   859 1341078 [pipesel] perl 733 cygthread::stub: thread 'pipesel', id 0x310, stack_ptr 0x2BBCCB0
> >   192 1341270 [main] perl 733 select_stuff::wait: m 3, us 18446744073709551615, wmfo_timeout -1
> >   196 1341466 [pipesel] perl 733 SetThreadName: SetThreadDescription() failed. 00000000 10000000
> > 
> > Pipesel never comes back.
> > 
> > Other info:
> > 
> > - Replacing cat with tee (tee with no args is the same as cat) makes it work. tee reads in smaller chunks, while cat reads at the pipe buffer size. Comments in select.cc suggest this is important, but I don't understand it all.
> > - Removing the curl makes it work
> > - Using curl </dev/null to make curl not touch stdin makes it work
> > - Using a Cygwin program instead of a non-Cygwin program e.g. id instead of curl makes it work
> > - Removing the select confirms that nothing weird is breaking the pipe, and the "abc' shows up properly
> > 
> > There was a report in MSYS2 https://github.com/msys2/msys2-runtime/issues/202 also about pipes to external programs, but there are some differences. In this scenario the non-Cygwin curl doesn't actually read anything from the pipe, and it should have exited before the select call. I tried a build of MSYS2 with their fix, and it still hangs in this way.
> 
> Thanks for the report. I looked into this problem, and found the cause.
> Let me consider how to fix that.

I have submitted the patch for this issue. Now it is waiting for the review.

Thanks.

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

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

end of thread, other threads:[~2024-03-10 10:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-10  5:49 Non-Cygwin programs touching a pipe's read side makes the write side unselectable wh
2024-03-10  8:38 ` Takashi Yano
2024-03-10 10:34   ` 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).