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 1pyeOG-0001lK-3E for pgsql-hackers@arkaria.postgresql.org; Mon, 15 May 2023 20:01:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pyeOE-00065c-L5 for pgsql-hackers@arkaria.postgresql.org; Mon, 15 May 2023 20:01:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pyeOE-00065J-Ar for pgsql-hackers@lists.postgresql.org; Mon, 15 May 2023 20:01:50 +0000 Received: from relay5-d.mail.gandi.net ([2001:4b98:dc4:8::225]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pyeO9-002wLi-89 for pgsql-hackers@lists.postgresql.org; Mon, 15 May 2023 20:01:49 +0000 Received: (Authenticated sender: adsend@dunslane.net) by mail.gandi.net (Postfix) with ESMTPSA id 4B3D31C0005; Mon, 15 May 2023 20:01:40 +0000 (UTC) Content-Type: multipart/alternative; boundary="------------s0QS0txGNBOZkUIAf4beI0DX" Message-ID: <26b0ebdb-3e7c-d562-620d-8e2f17286ff9@dunslane.net> Date: Mon, 15 May 2023 16:01:39 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Content-Language: en-US To: Andres Freund Cc: Tom Lane , pgsql-hackers@lists.postgresql.org References: <08dd6053-deee-52e9-954b-eb69232905c9@dunslane.net> <2506819.1681761221@sss.pgh.pa.us> <7d7dcc20-ba19-5340-9be8-f255e8b42edc@dunslane.net> <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> From: Andrew Dunstan Subject: Re: issue with meson builds on msys2 In-Reply-To: <20230515193817.ttx4qf3ceqeufls2@awork3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------s0QS0txGNBOZkUIAf4beI0DX Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2023-05-15 Mo 15:38, Andres Freund wrote: > Hi, > > On 2023-05-05 07:08:39 -0400, Andrew Dunstan wrote: >> If you want to play I can arrange access. > Andrew did - thanks! > > > A first observeration is that making the shell command slightly more > complicated, by echoing $? after pg_ctl, prevents the error: > > /usr/bin/perl -e 'system(qq{"bin/pg_ctl" -D data-C -w -l logfile start > startlog 2>&1}) ;system(qq{"bin/pg_ctl" -D data-C -w -l logfile stop > stoplog 2>&1;}) ; print $? ? "BANG: $?\n" : "OK\n";' > BANG: 33280 > > /usr/bin/perl -e 'system(qq{"bin/pg_ctl" -D data-C -w -l logfile start > startlog 2>&1}) ;system(qq{"bin/pg_ctl" -D data-C -w -l logfile stop > stoplog 2>&1; echo $?}) ; print $? ? "BANG: $?\n" : "OK\n";' > 0 > OK You're now testing something else, namely the return of the echo rather than the call to pg_ctl, so I don't think this is any kind of answer. It would just be ignoring the result of pg_ctl. > > So does manually or or via a subshell adding another layer of shell. > > > As Andrew observed earlier, the issue does not occur when not performing > redirection of the output. One interesting bit there is that the perl docs for > system include: > https://perldoc.perl.org/functions/system > >> If there are no shell metacharacters in the argument, it is split into words >> and passed directly to execvp, which is more efficient. On Windows, only the >> system PROGRAM LIST syntax will reliably avoid using the shell; system LIST, >> even with more than one element, will fall back to the shell if the first >> spawn fails. > My guesss is that the issue somehow is triggered around the shell handling. > > > One relevant bit: If I use strace (from msys) within system, the subprograms > (shell and pg_ctl) actually exit with 0, from what I can tell - but 33280 > still is returned. Unfortunately, if I use strace for all of perl, the error > vanishes. > > > Perhaps are some odd interactions with the stuff that InheritstdHandles() > does? I observed the same thing with strace. Kind of a Heisenbug. > > Andrew, is it ok if modify pg_ctl.c and rebuild? I don't know how "detached" > from the actual buildfarm animal the system you gave me access to is... > Feel free to do anything you want. This is a completely separate instance from the buildfarm animals. When we're done with this issue the EC2 instance will go away. If you use the script just run in test mode or from-source mode, so it doesn't try to report results (that would fail anyway, as it doesn't have a registered secret). You might have to force have_ipc_run to 0. Or you can just build / install manually. cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------s0QS0txGNBOZkUIAf4beI0DX Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit


On 2023-05-15 Mo 15:38, Andres Freund wrote:
Hi,

On 2023-05-05 07:08:39 -0400, Andrew Dunstan wrote:
If you want to play I can arrange access.
Andrew did - thanks!


A first observeration is that making the shell command slightly more
complicated, by echoing $? after pg_ctl, prevents the error:

/usr/bin/perl -e 'system(qq{"bin/pg_ctl" -D data-C -w -l logfile start > startlog 2>&1}) ;system(qq{"bin/pg_ctl" -D data-C -w -l logfile stop > stoplog 2>&1;}) ; print $? ? "BANG: $?\n" : "OK\n";'
BANG: 33280

/usr/bin/perl -e 'system(qq{"bin/pg_ctl" -D data-C -w -l logfile start > startlog 2>&1}) ;system(qq{"bin/pg_ctl" -D data-C -w -l logfile stop > stoplog 2>&1; echo $?}) ; print $? ? "BANG: $?\n" : "OK\n";'
0
OK


You're now testing something else, namely the return of the echo rather than the call to pg_ctl, so I don't think this is any kind of answer. It would just be ignoring the result of pg_ctl.



So does manually or or via a subshell adding another layer of shell.


As Andrew observed earlier, the issue does not occur when not performing
redirection of the output. One interesting bit there is that the perl docs for
system include:
https://perldoc.perl.org/functions/system

If there are no shell metacharacters in the argument, it is split into words
and passed directly to execvp, which is more efficient. On Windows, only the
system PROGRAM LIST syntax will reliably avoid using the shell; system LIST,
even with more than one element, will fall back to the shell if the first
spawn fails.
My guesss is that the issue somehow is triggered around the shell handling.


One relevant bit: If I use strace (from msys) within system, the subprograms
(shell and pg_ctl) actually exit with 0, from what I can tell - but 33280
still is returned. Unfortunately, if I use strace for all of perl, the error
vanishes.


Perhaps are some odd interactions with the stuff that InheritstdHandles()
does?


I observed the same thing with strace. Kind of a Heisenbug.



Andrew, is it ok if modify pg_ctl.c and rebuild? I don't know how "detached"
from the actual buildfarm animal the system you gave me access to is...


Feel free to do anything you want. This is a completely separate instance from the buildfarm animals. When we're done with this issue the EC2 instance will go away.

If you use the script just run in test mode or from-source mode, so it doesn't try to report results (that would fail anyway, as it doesn't have a registered secret). You might have to force have_ipc_run to 0. Or you can just build / install manually.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------s0QS0txGNBOZkUIAf4beI0DX--