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 1wRQ0b-002KPI-1E for pgsql-hackers@arkaria.postgresql.org; Mon, 25 May 2026 07:45:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wRQ0Y-000a8g-3B for pgsql-hackers@arkaria.postgresql.org; Mon, 25 May 2026 07:45:55 +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.96) (envelope-from ) id 1wRQ0Y-000a8X-0L for pgsql-hackers@lists.postgresql.org; Mon, 25 May 2026 07:45:55 +0000 Received: from fout-b7-smtp.messagingengine.com ([202.12.124.150]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wRQ0W-00000001JS8-0Pq1 for pgsql-hackers@lists.postgresql.org; Mon, 25 May 2026 07:45:54 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 75E631D000D1 for ; Mon, 25 May 2026 03:45:48 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Mon, 25 May 2026 03:45:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3; t=1779695148; x=1779781548; bh=VvXbo8YEJ/9Kkbnb1CoFzbLDqLJLVJIK 1L1k8UZXHp8=; b=MIEWma/xSdZ7nU1SU01owNp5wwHl5oKSjVLe+VSfQKuqOKi3 /T9/2h4fthl3vq57wn1yILUTx2uolYIlX/TqhLv5iLugCwYqJwT4YifV9CvlfyDT 4HBInKpbUhfT3Q2uSiQ9H28nO3lZHCcUgs79XdpRz3IbBXocuq0HM4Jl38giVe4r x8AgQBuRsBCK290Jbr79YvR9ShKHl0XD5UFUl9/ydDrbO5gU9oqj12v6OAcuE8x2 HaMvsSZQi5MzzcH+X1idps+KjFIJEkffDn+UCmfDV4mNqKbKFe3/F17NcErzRAN4 WrQqU2GCnCRv/rMJoiyAFK0AKM0pHoSfHSe9wA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1779695148; x= 1779781548; bh=VvXbo8YEJ/9Kkbnb1CoFzbLDqLJLVJIK1L1k8UZXHp8=; b=T L02nD2pYhw5YGnttikg77CLz2mX2YeSx9c+95UceRFh5MCZ7a+nKCKliKYh6mcZq S0a6DF43sM3YsZxnpqpD/cTiOE9tEe7Eip/muj3c02gMxUdmfPUI1+wsv5Kpd67t zp40pGCiseCy98Vt6mHvRZf/8U6o2sHzarvZQAeN2wtli4y1khg2/epcIkJF0Uab JdY6KsIV4WVl32qtoqcyQTCA2KTlrZY0XglbwBSKaW3JH4TvA4erx7bI2GqnDopb rCA3P7J/0Qrvy80c+pgNTtWaY67mJADVb/o4BhfF33GwtsVv9Zd8g/rW6ugKCtPw jQDkuerwqyp35RqJR+pyQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGQO2l7sA/1QQ1ca23IhDIzTa6yxzRXa1LuPQJI3RUbtaRMpSbOcdDCu6qKRtmG3H OARSyO4heMrgDdh8lkTtVPeW3/GVTc6nm+9irVW5iPcIs4F+Tgb1dzg+VjQdQg3Fh+jkTe T1GLRLmBuI8ckuH334sZ/V9auog8lDtBqONVw3NwSvRzLHop8b9cfao/gcjRds5CL4NtCt aJEW8uIuT/oY7MU7S2f7bLk8J9ISVED6a6HRLt3ygDthzF2gGRvBXw65a3rllW2S7CNxGP ZkjRFjfqXheNxgYMbWi7MSkkveyL48WqlH6/5UzXHttEykBhiV3HVN+2e3dtTGD9Ai6WlH QDJQRyMNGvqFAphrOA0an+4+fUo6jJIGjOdqABdVyszNn93rhS0XtVyhXojkxUAERTUCsf TPq6MSqvXydUj+h9s1res6quc+hXSUiosAokAhV851Znuj+R1ax2FT3lrXQQnxd22xLXzU M9nFD03gcZAt3OWuAQOJXw0DN3vNkV78bPc6TrZ4Q7e7u1fEBh7Vu8JH12kim6aGtZTC+F ra4/ZiiTTaceEGjBsZXlA3i0Pdh/RIAKkKzm709mwQFsgT8TJXHBn13cI584pGF2CUUJwy VAkZ6Cnr4FrzpzXDKqd4YCe23S+DPs36D+SHtmhiDUeJwBrcZN7n1XrnAJkg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 25 May 2026 03:45:47 -0400 (EDT) Date: Mon, 25 May 2026 16:45:41 +0900 From: Michael Paquier To: Postgres hackers Subject: NULL pointer dereference in syslogger with load_libraries() and -DEXEC_BACKEND at startup Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="YQ3UximkdTJ3bqcc" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --YQ3UximkdTJ3bqcc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi all, While doing some tests today for a different patch, I had the surprise to see the following failure on HEAD (not on REL_18_STABLE or older) while loading one of the test modules (I was playing with test_slru, one of the custom pgstats module fails equally). Reproducing this problem requires the following setup: - Module loaded by shared_preload_libraries - logging_collector active, which we don't do in most of the tests run by the buildfarm. - -DEXEC_BACKEND. - Use at least log_min_messages =3D debug1 to make load_libraries generate at least one message Then one is greeted by: =3D=3D465718=3D=3DUsing libbacktrace symbolizer. syslogger.c:1118:7: runtime error: null pointer passed as argument 4, which is declared to never be null #0 0x0000012b9331 in write_syslogger_file /home/ioltas/git/postgres/src/bac= kend/postmaster/syslogger.c:1118=20 #1 0x000001aa353a in send_message_to_server_log /home/ioltas/git/postgres/s= rc/backend/utils/error/elog.c:3889=20 #2 0x000001a9a3ce in EmitErrorReport /home/ioltas/git/postgres/src/backend/= utils/error/elog.c:1924=20 #3 0x000001a93b8b in errfinish /home/ioltas/git/postgres/src/backend/utils/= error/elog.c:555=20 #4 0x0000015ed3d7 in pgstat_register_kind /home/ioltas/git/postgres/src/bac= kend/utils/activity/pgstat.c:1574=20 #5 0x7ffff7fb3bcf in _PG_init /home/ioltas/git/postgres/src/test/modules/te= st_custom_stats/test_custom_fixed_stats.c:80=20 #6 0x000001aa6fd5 in internal_load_library /home/ioltas/git/postgres/src/ba= ckend/utils/fmgr/dfmgr.c:299=20 #7 0x000001aa653e in load_file /home/ioltas/git/postgres/src/backend/utils/= fmgr/dfmgr.c:161=20 #8 0x000001acbb15 in load_libraries /home/ioltas/git/postgres/src/backend/u= tils/init/miscinit.c:1838=20 #9 0x000001acbcb8 in process_shared_preload_libraries /home/ioltas/git/post= gres/src/backend/utils/init/miscinit.c:1856=20 #10 0x0000012a907b in SubPostmasterMain /home/ioltas/git/postgres/src/backe= nd/postmaster/launch_backend.c:678 Looking at a backtrace: #1 0x00000000012b934d in write_syslogger_file ( buffer=3D0x2fba5d0 "2026-05-25 16:21:58.516 JST syslogger[465718]: [1-1] db=3D,user=3D,app=3D,client=3D LOG: registered custom cumulative statistics \"test_custom_fixed_stats\" with ID 26\n", count=3D159, destination=3D1) at syslogger.c:1118 1118 rc =3D fwrite(buffer, 1, count, logfile); (gdb) p logfile $1 =3D (FILE *) 0x0 It is pretty clear that we have the idea to log an entry through the syslogger but it is too early to do so and its file is not opened, so my bet is that something in the startup logic has changed. I did not take the cycles necessary for a bisect, but it looks like this has been around for a few months at least. I have pinged f3c9e341cdf1 as a safe startup point for now, so that's a 2026 issue. Does this ring a bell to somebody? -- Michael --YQ3UximkdTJ3bqcc Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmoT/iUACgkQnvQgOdby QH19qg//WakIxf3I7dRR8Zhz9Pxmf7M5SMVzSoRTRxUT4/PIjdgUw875mS3COJIl 8IsRVp9ZLLzgl2DVud4ZrgSIg0cl/QsawrBTDcAsETFNrJqEoeqaCZerRnPrrnQN GiRHBw2R5MXiweNsbBXQXC6YZnqhVS5SW57cjFuBVba7m6UJvmsaB2MCiLQ0G9pJ DmtkGt+vwBIbXJjHUI0AeOhNIemRYfDC/T1RNR0K5KdNA2jRGDnEc+Q+TppN0FEJ VsomkKPX5o/48YgBf53JQOaPwM6QnSVQCCGjJWN9Ic4uxiX5+zmnGtqfMHLW6TKu kP+sV87EL0BYcdWfXxhmE+Fg+JotJcbuz5TpT+4S+jGvUvfraVr52QPbUZqHzMfy QQbGDu+9SxRZTrzXyUiIZFam03vJCapgiHKpiFbtH6I/6cYF9qf6mvBEeSvcFPm3 gh3n9ne6TWIW7Bk3n9fhCfOXRzi057mjDj+HI9ybFLrFuEhZR5uIwcKD5PkwRf7y DICdwouRDbBG71NR4GzSD6XNu5kfGIQ2koLmqL8fv8WdN7Pto1IFzfV27Kt/m3Sk 2Wq8LsH3iXPJA3HgF62CgrnxfWe5bxRm5FGsKH8j7h6JWDOjsYVhDVii0QBcbcqb 0ctZNHLyeCCl1YPXu3SsOSXSo0sW6Inc5PQxKVSDGWI0k7RCiFg= =HRiP -----END PGP SIGNATURE----- --YQ3UximkdTJ3bqcc--