Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pygjJ-0002yu-SE for pgsql-hackers@arkaria.postgresql.org; Mon, 15 May 2023 22:31:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pygiJ-0005EM-Db for pgsql-hackers@arkaria.postgresql.org; Mon, 15 May 2023 22:30:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pygiH-0005E5-Ol for pgsql-hackers@lists.postgresql.org; Mon, 15 May 2023 22:30:43 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pygi9-0000kE-Uo for pgsql-hackers@lists.postgresql.org; Mon, 15 May 2023 22:30:40 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id CCF043200A23; Mon, 15 May 2023 18:30:30 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 15 May 2023 18:30:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1684189830; x=1684276230; bh=aX kjlMOuEU6GZmodQGykndKpvNitVNZECsoF6frhhP0=; b=MZLe9+wlTQhvKKFBBV J5YVf5TRlOieBC8AUb4Bjs2RFsmLtNWMko/KELTkqNEByL7EfLdQiHStktueWqRX /neAAQdSNqYfbGlt1lHfFYfKMqUeEW/K/7BjZX8CgSuwMYkgNDKfYj9fWb/xdXvp yqy9ybNJI8ot+42KxGfYg3SV9wiYe4M12ztwOhRHzl6M8NfgG1P6T0zykzicsJmi 5swXf8Ia7WRWSq2VrGcw4JZPfRfzG4t9M2o3hdptZi5K75bWn/8DEuC+ssw7SMoA UmNTpGJZeBBSL9ZmIXp25CXCAoCg/xxwMUhgbzi7zV3EQhN4cgSDy8HdqY8P+Gxa SH9A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684189830; x=1684276230; bh=aXkjlMOuEU6GZ modQGykndKpvNitVNZECsoF6frhhP0=; b=x12DTSqCku5j1u7vsIvfQbBnJaqbl jnhANNwidK1ViGkHWUFpUZLpmWUE20hwVLzu0rCW61f6jfMJ4oHxduY127FUnx/O ll3U4NUQ4rWFeAl7wbjB3Q7tGj6w5wJFDwWKOR2XB784xiVRaOwsic/9LjsqnpHy U5gNB0uuRg4/C9iXIjDq0VobwNdNYrHTjXYngulwCjhPJpWmCXHxl/0a1ZphaHXF LtrPoHqXO692yqsyfrlEobAuTTWWpqud+hh0AT746jjk5xRc/Li6LxhCmwybab7K xgaw05cRkiMaRLgos11rIOa/wCJD3u3Uff+00GG6xfXyImNeDThcP7TfQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeehkedgudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepvdfffeevhfetveffgeeiteefhfdtvdffjeevhfeuteegleduheetvedu ieettddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 May 2023 18:30:29 -0400 (EDT) Date: Mon, 15 May 2023 15:30:28 -0700 From: Andres Freund To: Andrew Dunstan Cc: Tom Lane , pgsql-hackers@lists.postgresql.org Subject: Re: issue with meson builds on msys2 Message-ID: <20230515223028.gkctmcoe7jtd5mmw@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230515201326.tbjgfdef6ul6oqfd@awork3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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