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.96) (envelope-from ) id 1wRkDt-002eIK-1v for pgsql-hackers@arkaria.postgresql.org; Tue, 26 May 2026 05:21:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wRkDr-002uZL-1u for pgsql-hackers@arkaria.postgresql.org; Tue, 26 May 2026 05:21:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wRkDr-002uZD-0x for pgsql-hackers@lists.postgresql.org; Tue, 26 May 2026 05:21:00 +0000 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wRkDq-00000000nyi-2Cu3 for pgsql-hackers@lists.postgresql.org; Tue, 26 May 2026 05:20:59 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id A14CFEC0078; Tue, 26 May 2026 01:20:57 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Tue, 26 May 2026 01:20:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1779772857; x=1779859257; bh=EehOhjWi/U /hj2zxtqlskWHVEWhxniH/cQq7bpwKRs8=; b=L9BUmuBUgbzkJkq2rBXu5lDX+J D2y6DqQbbne+vEVpdrUlYtMpleF6Hg5CCASjHuWo6NBkW/rmX8yFDXqHwbmvVaEn T35lf4PjjNjPUSS47yAjUUVDrufpDJaNbEOpyAl5DfmvfBoZNKux7pVs/Jm1W0g0 +msEr7z0zVZRFlscmf40vRMrV8xBFPzopiZtmGnB2OoFhI8K86Ij/OVekVfMFCIE 2Y78m5E6ykYX2X+6AJigHvs+CDXBlGCoMKBSA5LbSIRcaNSkRZE91l/P4xNE6SjW zhl5U8e4GqUrzMOvvY5vA/9G3CYUm53KL/15jmueB5H+d+13dDQx2zqofNnw== 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:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1779772857; x=1779859257; bh=EehOhjWi/U/hj2zxtqlskWHVEWhxniH/cQq 7bpwKRs8=; b=DuNenTkVvYKKM8meoo0BBzRRr1mPcv1OpOTbC2Pdc9WnMoW1im/ 4CmUld15SqZLNTgsROtYSVxlWndCVQMSLDMuxPCXRuJWqHElgRDqlmY7zOL+OGt9 8Vj2BhF4PEJq1P2Kh2Fz1w/hmaF/dpGIsUxdANyLwGQeVn1ePLPJDwSx4BLjzWS/ 44yX5tx239cLkIqQGvawE/CmHu5bjSVViAaqpsb7APMuOe89s9VtLXNdaYX3oNl7 bK1KWNJ9UEdWnxufy+C8zJORNi6Dd2f6ZLP2quLVcDgQ3+TCikbse14rOpbqABVb Zw8NQgE1LqCXa01MYyWrAfSlEzVOlf+JmEw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEg7Z0/bCpR7kSJ9nNk5I6zmwVJ8FeCbLD7dM/VJhb8gmlFVqDFTAL4ihwLm7kV8+ ogf32IHsfBlep6ctAlJs4Y6Ba+nDVloNv0kDPNwq50XPtEw491GQO+9km+/3SM0dtn12IB iM3gH7f4mmvNVhDPW4krJ3COE76yJ1/RpLCOrc00LMypR0p+wlAf5d1xVGYzR3F4+8b5al 48JUYjYrRjBexN74Gh3QY8gjNBQ8FR7Ndy7ebJk6zG4y0Q68v1nJBmQGQ2CAkfutSpg9/R X6xuh5/CfyW6cTRkVXqy08amPetvDHJEQW8lpFnlgTMFa7QsXlRj5knWmlEDyWDe4rKQMl nd3GtnXd5DrsKa4EK8mVT8pRuhrcJJd1XF6vIc1Y1z+nTZEHk5Y7You+kGVuEob6KEWsMC rXagJna5wKpqKS3f1ERqURpOBIqqFJ99LIgVyW4kCTfJ5k29bEMzO+3zr2hl8s9m5p+1Tf 9yn1x87fXggWPv/AGb+26jVM0mMZGxqqL8Xtj8J4YePLc0DVMMjykg6zeVT1gpplyPnT1o fpCZQpm/WcH+FfBotDdL9etuVY5uwmsFBNvRLD77SoFTllKU3zj0udh9mBxsPUFlQm/8Mu xGcODDP7XX8ObktBQ4B4zr0A/5vvht8TDvq4TO+u75tgDuOZgHu7qpivfEdg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 26 May 2026 01:20:56 -0400 (EDT) Date: Tue, 26 May 2026 14:20:52 +0900 From: Michael Paquier To: Euler Taveira Cc: Postgres hackers , =?iso-8859-1?Q?=C1lvaro?= Herrera Subject: Re: NULL pointer dereference in syslogger with load_libraries() and -DEXEC_BACKEND at startup Message-ID: References: <746eb248-0787-4633-94fe-f3dbef249f85@app.fastmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Azo1zuNv3kijY5/m" Content-Disposition: inline In-Reply-To: <746eb248-0787-4633-94fe-f3dbef249f85@app.fastmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Azo1zuNv3kijY5/m Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 25, 2026 at 11:39:54PM -0300, Euler Taveira wrote: > It seems I was too optimistic about this patch. Since the commit 0c8e082f= ba8 > sets MyBackendType to B_LOGGER earlier, it breaks the following assumptio= n in > syslogger.c. >=20 > /* > * If we're told to write to a structured log file, but it's not = open, > * dump the data to syslogFile (which is always open) instead. T= his can > * happen if structured output is enabled after postmaster start = and we've > * been unable to open logFile. There are also race conditions d= uring a > * parameter change whereby backends might send us structured out= put > * before we open the logFile or after we close it. Writing form= atted > * output to the regular log file isn't great, but it beats dropp= ing log > * output on the floor. >=20 > It shouldn't assume syslogFile is always open. The send_message_to_server= _log() > shouldn't be executing the following code path in this case. This comment has been rewritten in 2022 when jsonlog was added in dc686681e079, but this assumption is much older than that: bff84a547d71, where the syslogger has been made more robust. And we assume that the log file is always open, so this change is breaking an old assumption. > It could set MyBackendType only if child_type !=3D B_LOGGER during > launch_backend.c and set it at the same code path as in the past. However= , I > consider this solution ugly and hackish. While thinking about an approach that could allow to keep 0c8e082fba8d, I was wondering whether we should have a boolean flag that tracks if the log file is opened or not that gets set (we should not care about the reset) when we are done with its creation, but I'm feeling that this makes the logic feeble. We know only rely on MyBackendType for the job which means to complicate all these checks. The part that makes me uneasy is that the logging facility should be robust by design, and simpler is always better IMO. An exception where we don't set MyBackendType and have an exception for this corresponding child_type value does not really feel right to me either.. As a whole, I am not sure to like what has been done here. -- Michael --Azo1zuNv3kijY5/m Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmoVLbQACgkQnvQgOdby QH2vQBAAlJ9i/Uk+bD5FH7XSrocw/k/izTQD8hb+r3bZPcAi/9z6B3l9+Yyp4oUq mkngAn2HEhL6QH3zoA/UM6fFsFgpZ8D583juTLP4dGUU8hpSyEpwRbOvVoNOXzTR JemCjptI33FLNWBI3883B/MddGFLCK6j2wm8mgwqRYHajGPMwvoVbuhDQhHTMIx6 PaMtImjK5A0x1ZtAxh04Mf2hpN1k2k7UoJdoc52SXUkUmzMkZdqizgNHyA2pIzF1 bQtqbBRrT4tITzU8MxbH7AK0Jqjrbt38C+rDvDOgYW2FqVIb7ELujT0XilLlTERD emAWWMbgpfkoTEOTEpQPUyM+FYyQL/t3FNEiSzX+U26lb0QOT3menbNghnx17hyf Mh4wNmqtuOXO66IMl5Qp/UlSgpnRxHwTqPHh/j57gcZWjTEwFZGPieJSchJw1bmO qM6j3fH4u7mCuv7h0kC1dYsJH20dyghIuK1nkXCYTgx+hoQomy/d7q0Ovq9p9brY dKS0EWd2142PzDM9oYJ84VKUFyobkPsJjbUIaEm/iSGJx88wavlnIJK48ohvuWh1 PJ/jAy1LJaOZzSE9xmE1iO1i7fw9oUrmsb82rZsoFTYvOAq1TVEmakK2Gty09xAT ND+ViE7K9cF1IlcoZ43ce7afWoofFpJ+qVT5f03uXSbXyvbSayM= =Jr9a -----END PGP SIGNATURE----- --Azo1zuNv3kijY5/m--