From: Andres Freund <andres@anarazel.de>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: issue with meson builds on msys2
Date: Mon, 15 May 2023 15:30:28 -0700
Message-ID: <20230515223028.gkctmcoe7jtd5mmw@awork3.anarazel.de> (raw)
In-Reply-To: <20230515201326.tbjgfdef6ul6oqfd@awork3.anarazel.de>
References: <20230420150652.jciazjap223iznjp@awork3.anarazel.de>
<5bddd941-9819-6655-7a71-3f346050583e@dunslane.net>
<6efeb45a-07f9-2291-c8f8-9fb4abbb6ebc@dunslane.net>
<20230427221828.2qo7z4xb4f7islln@awork3.anarazel.de>
<236c0354-62b1-0ae1-a252-4c866bc1c5d6@dunslane.net>
<20230504235413.eibaxlxslo76ipjl@awork3.anarazel.de>
<2ff71af4-cdee-37b8-525a-2b25afd1769a@dunslane.net>
<20230515193817.ttx4qf3ceqeufls2@awork3.anarazel.de>
<26b0ebdb-3e7c-d562-620d-8e2f17286ff9@dunslane.net>
<20230515201326.tbjgfdef6ul6oqfd@awork3.anarazel.de>
Hi,
On 2023-05-15 13:13:26 -0700, Andres Freund wrote:
> It wouldn't really - the echo $? inside the system() would report the
> error. Which it doesn't - note the "0" in the second output.
Ah. Interesting. Part of the issue is perl (or msys?) swalling some error
details.
I could see more details in strace once I added another layer of shell
evaluation inside the system() call.
190 478261 [main] bash 44432 frok::parent: CreateProcessW (C:\tools\nmsys64\usr\bin\bash.exe, C:\tools\nmsys64\usr\bin\bash.exe, 0, 0, 1, 0x420, 0, 0, 0x7FFFFBE10, 0x7FFFF
BDB0)
--- Process 7152 created
[...]
1556 196093 [main] bash 44433 child_info_spawn::worker: pid 44433, prog_arg ./tmp_install/tools/nmsys64/home/pgrunner/bf/root/HEAD/inst/bin/pg_ctl, cmd line C:\tools\nmsys6
4\home\pgrunner\bf\root\HEAD\pgsql.build\tmp_install\tools\nmsys64\home\pgrunner\bf\root\HEAD\inst\bin\pg_ctl.exe -D t -w -l logfile stop)
128 196221 [main] bash 44433! child_info_spawn::worker: new process name \\?\C:\tools\nmsys64\home\pgrunner\bf\root\HEAD\pgsql.build\tmp_install\tools\nmsys64\home\pgrunne
r\bf\root\HEAD\inst\bin\pg_ctl.exe
[...]
--- Process 6136 (pid: 44433) exited with status 0x0
[...]
--- Process 7152 exited with status 0xc000013a
5292450 5816310 [waitproc] bash 44432 pinfo::maybe_set_exit_code_from_windows: pid 44433, exit value - old 0x0, windows 0xC000013A, MSYS 0x8000002
So indeed, pg_ctl exits with 0, but bash ends up with a different exit code.
What's very interesting here is that the error is 0xC000013A, which is quite
different from the 33280 that perl then reports. From what I can see bash
actually returns 0xC000013A - I don't know how perl ends up with 33280 /
0x8200 from that.
Either way, 0xC000013A is interesting - that's 0xC000013A,
STATUS_CONTROL_C_EXIT.
Very interestingly the problem vanishes as soon as I add a redirection for
standard input into the mix. Notably it suffices to redirect stdin in the
pg_ctl *start*, even if not done for pg_ctl stop. There also is no issue if
perl's stdin is redirected from /dev/null.
My guess is that msys has an issue with refcounting consoles across multiple
processes.
After that I was able to reproduce the issue without really involving perl:
bash -c './tmp_install/tools/nmsys64/home/pgrunner/bf/root/HEAD/inst/bin/pg_ctl -D t -w -l logfile start > startlog 2>&1; ./tmp_install/tools/nmsys64/home/pgrunner/bf/root/HEAD/inst/bin/pg_ctl -D t -w -l logfile stop > stoplog 2>&1; echo inner: $?'; echo outer: $?
+ bash -c './tmp_install/tools/nmsys64/home/pgrunner/bf/root/HEAD/inst/bin/pg_ctl -D t -w -l logfile start > startlog 2>&1; ./tmp_install/tools/nmsys64/home/pgrunner/bf/root/HEAD/inst/bin/pg_ctl -D t -w -l logfile stop > stoplog 2>&1; echo inner: $?'
inner: 130
+ echo outer: 0
outer: 0
If you add -e, the inner: is obviously "transferred" to the outer: output.
As soon as either the pg_ctl for the start, or the whole bash invocation, has
stdin redirected, the problem vanishes.
Greetings,
Andres Freund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: andres@anarazel.de, andrew@dunslane.net, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org
Subject: Re: issue with meson builds on msys2
In-Reply-To: <20230515223028.gkctmcoe7jtd5mmw@awork3.anarazel.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox