Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r9Ann-00EnJt-L6 for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2023 21:12:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r9Anl-009Q1J-I1 for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2023 21:11:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r9Anl-009Q19-6z for pgsql-hackers@lists.postgresql.org; Fri, 01 Dec 2023 21:11:57 +0000 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r9Ang-009cOb-CN for pgsql-hackers@postgresql.org; Fri, 01 Dec 2023 21:11:54 +0000 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6cd0a8bc6dcso689921a34.2 for ; Fri, 01 Dec 2023 13:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=neon.tech; s=google; t=1701465110; x=1702069910; darn=postgresql.org; h=in-reply-to:references:from:to:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Eu2YTZqBmtU3sasp+HUfdvYaHh6OGocznNyOvWLzRd8=; b=q19EsbegZPwl+jFaLVFzVI9ODTzt079WQMzxv7XXAqW4NN0ABwdaNvkqHH5kosTR7Z I2ubGJ42W7MEoBw8azUCyiniGx2r5qTJw5eAoFuyG3ZZwfbA1ZYRPHKL0y6CARPdePgo rr16xU187VU670F1dZBCTElKSMKYV0Q0CgNuE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701465110; x=1702069910; h=in-reply-to:references:from:to:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Eu2YTZqBmtU3sasp+HUfdvYaHh6OGocznNyOvWLzRd8=; b=CYsmzGlML1CAnZWopI6gSpFoU+c5FpWm8FQHNlHsMD77Rne/s5q8cQNquXjz3XG1km o9gyxMaJuAzkXhwAG8EZia/XTXl2FkROxcYRfrUlyoEkXMkzvqA3RiOcHyLaXgQZuw4W 5h0PBt9z7x4JcTe2Bu79BmQ+CHPb15EF7UPuKmRP7JDykk/oqRsFeGNu71rL9PPKpF0Q m/dDysTkxGOUZNaStSrXdYLE+4y39LFeB3JlOX090dgpm85xv0M1rkkusIoSHCHFx3Mp epZSlWiLgj6DWNRwbFWONGBIkO1PaZvclkWNMsM+FE0vexli4scfI0LKsLKnXk7naG8U fIpw== X-Gm-Message-State: AOJu0Yy/3LkySk8kTMjiUzRTdEkZk67S03cFlgf0aCM0AotTOtDsBRKB lDSPN84AgZippEnisg68HDTWFA== X-Google-Smtp-Source: AGHT+IFy4P09eSvdUrMwViuJVWC/yzDVXDzT7rW6h/GRcdG94f/UXOiEtTcVyIPvcp5Q6WoQcCy3DQ== X-Received: by 2002:a05:6870:788c:b0:1e9:d158:7e85 with SMTP id hc12-20020a056870788c00b001e9d1587e85mr176584oab.30.1701465110462; Fri, 01 Dec 2023 13:11:50 -0800 (PST) Received: from localhost ([2607:fb91:128d:c7a0:3996:e070:71ee:42fb]) by smtp.gmail.com with ESMTPSA id gb17-20020a056870671100b001f9fe9e05desm995131oab.36.2023.12.01.13.11.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Dec 2023 13:11:50 -0800 (PST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8; format=Flowed Date: Fri, 01 Dec 2023 15:11:49 -0600 Message-Id: Cc: "pgsql-hackers" , "Thomas Munro" Subject: Re: Refactoring backend fork+exec code To: "Heikki Linnakangas" , "Alexander Lakhin" , "Andres Freund" From: "Tristan Partin" X-Mailer: aerc 0.16.0-85-g0be135a38186 References: <7a59b073-5b5b-151e-7ed3-8b01ff7ce9ef@iki.fi> <20230710225043.svl7fqxecwshwc7a@awork3.anarazel.de> <119551e6-60f6-49b2-ae04-a382a89f900c@iki.fi> <3b02a5a1-81ea-44e4-a09e-c0a594a4cef8@iki.fi> <014768ed-8b39-c44f-b07c-098c87b1644c@gmail.com> In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri Dec 1, 2023 at 2:44 PM CST, Heikki Linnakangas wrote: > On 01/12/2023 16:00, Alexander Lakhin wrote: > > Maybe you could look at issues with running `make check` under Valgrind > > when server built with CPPFLAGS=3D"-DUSE_VALGRIND -DEXEC_BACKEND": > > # +++ regress check in src/test/regress +++ > > # initializing database system by copying initdb template > > # postmaster failed, examine ".../src/test/regress/log/postmaster.log" = for the reason > > Bail out!make[1]: *** > >=20 > > ... > > 2023-12-01 16:48:39.136 MSK postmaster[1307988] LOG:=C2=A0 listening on= Unix socket "/tmp/pg_regress-pPFNk0/.s.PGSQL.55312" > > =3D=3D00:00:00:01.692 1259396=3D=3D Syscall param write(buf) points to = uninitialised byte(s) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0=C2=A0=C2=A0 at 0x5245A37: wri= te (write.c:26) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0=C2=A0=C2=A0 by 0x51BBF6C: _IO= _file_write@@GLIBC_2.2.5 (fileops.c:1180) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0=C2=A0=C2=A0 by 0x51BC84F: new= _do_write (fileops.c:448) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0=C2=A0=C2=A0 by 0x51BC84F: _IO= _new_file_xsputn (fileops.c:1254) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0=C2=A0=C2=A0 by 0x51BC84F: _IO= _file_xsputn@@GLIBC_2.2.5 (fileops.c:1196) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0=C2=A0=C2=A0 by 0x51B1056: fwr= ite (iofwrite.c:39) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0=C2=A0=C2=A0 by 0x552E21: inte= rnal_forkexec (postmaster.c:4518) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0=C2=A0=C2=A0 by 0x5546A1: post= master_forkexec (postmaster.c:4444) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0=C2=A0=C2=A0 by 0x55471C: Star= tChildProcess (postmaster.c:5275) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0=C2=A0=C2=A0 by 0x557B61: Post= masterMain (postmaster.c:1454) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0=C2=A0=C2=A0 by 0x472136: main= (main.c:198) > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0 Address 0x1ffeffdc11 is on th= read 1's stack > > =3D=3D00:00:00:01.692 1259396=3D=3D=C2=A0 in frame #4, created by inter= nal_forkexec (postmaster.c:4482) > > =3D=3D00:00:00:01.692 1259396=3D=3D > >=20 > > With memset(param, 0, sizeof(*param)); added at the beginning of > > save_backend_variables(), server starts successfully, but then > > `make check` fails with other Valgrind error. > > That's actually a pre-existing issue, I'm seeing that even on unpatched= =20 > 'master'. > > In a nutshell, the problem is that the uninitialized padding bytes in=20 > BackendParameters are written to the file. When we read the file back,=20 > we don't access the padding bytes, so that's harmless. But Valgrind=20 > doesn't know that. > > On Windows, the file is created with=20 > CreateFileMapping(INVALID_HANDLE_VALUE, ...) and we write the variables= =20 > directly to the mapping. If I understand the Windows API docs correctly,= =20 > it is guaranteed to be initialized to zeros, so we don't have this=20 > problem on Windows, only on other platforms with EXEC_BACKEND. I think=20 > it makes sense to clear the memory on other platforms too, since that's= =20 > what we do on Windows. > > Committed a fix with memset(). I'm not sure what our policy with=20 > backpatching this kind of issues is. This goes back to all supported=20 > versions, but given the lack of complaints, I chose to not backpatch. Seems like a harmless think to backpatch. It is conceivable that someone=20 might want to run Valgrind on something other than HEAD. --=20 Tristan Partin Neon (https://neon.tech)