pipe hang issue when running as SYSTEM

Takashi Yano takashi.yano@nifty.ne.jp
Tue Mar 22 13:17:56 GMT 2022


On Tue, 22 Mar 2022 19:18:07 +0900
Takashi Yano wrote:
> On Mon, 21 Mar 2022 11:45:57 -0700 (PDT)
> Jeremy Drake wrote:
> > This issue was reported to MSYS2 as a hang when trying to build libxml2 in
> > a Windows docker container.  Another user was able to come up with a
> > simple reproducer and a reasonable theory as to why it happens.  The msys2
> > issue is https://github.com/msys2/msys2-runtime/issues/77, and I will
> > quote the reproducer and analysis here:
> > 
> > I am having the same issue when building mingw. I managed to reduce the
> > issue to the following shell script:
> > 
> > #!/bin/sh
> > seq 1 99999 > big_file
> > eval '$(eval cmd.exe /c "type big_file" | : )'
> > 
> > When running as a normal user this completes immediately, but when run as
> > a system service it hangs forever. The issue appears to be that when
> > running under the SYSTEM account, the third sh process holds open the read
> > end of the pipe. Since cmd has too much output to write all at once, it
> > waits until the pipe's buffer has room to write more, but since sh isn't
> > actually reading from the pipe, this hangs forever. When running as a
> > normal user the read end of the pipe is not kept open, and so cmd.exe gets
> > an error when attempting to write and exits immediately.
> > 
> > My suspicion is that this is caused by f79a461 (which keeps the read end
> > of the pipe open) and b531d6b (which changes the behavior depending on
> > whether or not the program is running as a service).
> 
> Thanks for the report. This is expected problem as mentioned
> in b531d6b commit message. However, I could not imagin the
> situation that the service has multiple writer for the pipe
> and one of them is a non-cygwin app.
> 
> Question is: Does the docker invoke the command using SYSTEM
> account? Or is the processes in docker determined as running
> as a service?

I confirmed the processes in Windows docker are running as
well_known_service_sid. Let me consider a while.

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


More information about the Cygwin mailing list