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 1wNjRV-0011Fb-0R for pgsql-hackers@arkaria.postgresql.org; Fri, 15 May 2026 03:42:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wNjRT-00G4mn-1p for pgsql-hackers@arkaria.postgresql.org; Fri, 15 May 2026 03:42:27 +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 1wNjRT-00G4mc-0v for pgsql-hackers@lists.postgresql.org; Fri, 15 May 2026 03:42:27 +0000 Received: from mail-yx1-xb136.google.com ([2607:f8b0:4864:20::b136]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wNjRR-00000000gbo-1DGt for pgsql-hackers@postgresql.org; Fri, 15 May 2026 03:42:27 +0000 Received: by mail-yx1-xb136.google.com with SMTP id 956f58d0204a3-65c364b893aso10559864d50.0 for ; Thu, 14 May 2026 20:42:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778816543; cv=none; d=google.com; s=arc-20240605; b=MNadlTnJTwMsWi+glQNPAA2Jn5Ljgdgp1Y4YQfyps0CFuloCdBYlApEJuNg09aJXhw nv1q2O45kNnLxh6s7mJ4UcG6rU7DYxTXC/Tmop3wE4jA7JUq1tbMj1IJ3rMiKUFqpIuh Rp6s5F/xXPi9v0KFS5hL6+YgMAnkH0ua0v8AL42xAknmNTxmWjJd8glar3hYsH67riET pno0ucZMts5Qe2DhZ5iPgmnjrnIed6m4l/X68LYOXutcOhoantVNdMuFMn767Fmj/Qwp 8ob+EQpfiLaRVZjRrSvg1ApK3CbQKO2JOiOtLTZGwHY8pA2tTow1By7If+85/TSBlmDq 7BnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=hsAH8cHMdfQcSIZuaB6ndy+0NQhFt0mq1NNWqYPdAqA=; fh=2zSQZfKdmhwzAOqZC07nBJoHnw6XGaE3I4pRylMnrzM=; b=h+lLfcK4cy6qAnKTag7A7rlVG1WTBmL1DP/ueJGvfAfW0vZjimfGf1q9TkypepgnjP 5hqZ6dN5xDEqjPat7iJHRsO29TGNNH+NB24an5m+hNG+yTKotcFAs+cDGF1a9x5JBpOr mtnXjZ8+lzhc4SGhtyMie4DheJv9LmCvyzS3z8kv9F6LgQO1U72Y+vHJ1bGdhprEBWu+ yB389zGMpzSr6uZE1IaSJkqDKXsXk40ltK+qmYbka2KpQZCy/MlNbmkVE1J0dp7F3eRf aaju7PHHBIs7Bk7W8VhEdHS6glTI+l7lXh25UM3ON6DQXrcse50GivtVkhzJsSMqHxZA rxtA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778816543; x=1779421343; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=hsAH8cHMdfQcSIZuaB6ndy+0NQhFt0mq1NNWqYPdAqA=; b=i9iBQpl9BP80mEU90apxBNtEgZs4H9LwUGmEplXUGkpE6qVgZcAyCFDfdzFuDaCcGf DWX5hQj07GPq6R9jtIF1XEXZPObgo5+FqBvgJwgse1J8wElTQm1DvyMBBR5SuciJZmzM Y+ntErPUG48/cu9VljeMTwGuY9fqA2nmIArDZ8XNbBGTEH46/FnvO3q6qhDeZ876+dKM 6vSDDY/HV7cML4Tqqpsw0vZsEhLMqCqboWKC1uYg68TlztyNRevCx9hDMOtRAQPZifXi dvfsaoukT4ZhYwzvOTBqhWyASISjQxdhge5hlJzZ68EFCCt23CX65uYYnFZwYRw4wbYk n8tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778816543; x=1779421343; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hsAH8cHMdfQcSIZuaB6ndy+0NQhFt0mq1NNWqYPdAqA=; b=kCr/lBxwnDHs3BE4noKvTvjfTJJIfNNKa2aBKpjyCppepQg570Me8B/Wa1rmNkhgdZ RO16g28ZOtFqxVJB1/iscpfDdkUcaGuQN/JZiMEWPU12OviTay3wSzz6394jN4f8DHgi t1alBhCGZ9AHXeVvrncpf43Tq0dhBrzf0VdRJCcpcLyLZT3qxCfPg5+/0Levf3da+WSK RSYjru5kDuBDBhUBffzJWcXdMGgi7k2SP1EAoKJ44BVtp0L+iXYbdZN5yWlosTI+0eyc bugf+VNQX3UlpbuhMLtLZdF97jnipqKlzVIoNvyDgElDmobKzjf//kD4sibgJFq2OEq6 rmMA== X-Gm-Message-State: AOJu0YzJRaDk+R8nsx8zJ8DkAqZn4R2+eFYyYTCUaBd4ATeWfrHvN9cG XVUqp8ah1aMYIiBlmTweIG/My/ju9oFxI+3GNnCSsrRDPWidokLwwjNElTJyIyQ9eBmAaym6mZ+ ZRK9Gdn424A9fLvDiTKYf8dWnJKJSoV8= X-Gm-Gg: Acq92OETH77VSXzyVM/B1pY9egjIqyIXFe/t3qaC8lh6CvQrzW0KJei7SBNcW9QAhUe YEqLNwHXu0uadTOAxsKbUCnuykz+Vn1rYTAYsT9MyGSX6Bt2blGMhe2lr1ybVMf0aYjHxSLIyQ6 /g23ACBukano89lpycYeEGZs2c8CDM66xR4ikLNbRDu6x7Sz1/+3Mdb9mrSmP4bK1+UM8ZCbt7q nYMmXZOiqsR1+8wH+3La11DTZ2P9Qijn6j6+j2KFwHBMiZt/k0Dw7piEj1SB9NripuATEnBF5L+ uTn9qQ== X-Received: by 2002:a05:690c:6608:b0:7b2:1bf1:8016 with SMTP id 00721157ae682-7c9593b7207mr24321687b3.2.1778816543096; Thu, 14 May 2026 20:42:23 -0700 (PDT) MIME-Version: 1.0 References: <497296e5b4ccdcbec80607beda7f18abbcc1a254.camel@j-davis.com> In-Reply-To: <497296e5b4ccdcbec80607beda7f18abbcc1a254.camel@j-davis.com> From: Ayush Tiwari Date: Fri, 15 May 2026 09:12:11 +0530 X-Gm-Features: AVHnY4L2D2oUJxXtj0sSncuPUwwzgw8jD8QlZyGCc8HzUStiWPwtzvQXNY1-nbk Message-ID: Subject: Re: Add a guard against uninitialized default locale To: Jeff Davis Cc: pgsql-hackers@postgresql.org Content-Type: multipart/alternative; boundary="0000000000002c0de30651d30021" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000002c0de30651d30021 Content-Type: text/plain; charset="UTF-8" Hi, On Fri, 15 May 2026 at 03:30, Jeff Davis wrote: > On Fri, 2026-04-24 at 15:44 -0700, Jeff Davis wrote: > > Not known to be reachable after dbf217c1c7, but defend against > > similar > > issues in the future. For instance, an extension might encounter the > > problem by calling pg_newlocale_from_collation(DEFAULT_COLLATION_OID) > > from _PG_init(), and end up with a NULL pointer dereference. > > > > Backport through 17, though patch is different in 17 (also attached). > > I plan to commit and backport this soon. > > The patch looks good to me as it is. Just one nit in PG 17 patch: The provider == '\0' sentinel is correct (valid providers are 'b'/'c'/'i'/'d', all nonzero) and the three guarded sites (lc_collate_is_c, lc_ctype_is_c, pg_newlocale_from_collation) cover the direct consumers symmetrically. The only thing maybe consider is replacing the bare /* should not happen */ above the '\0' test with something like /* provider unset; init_database_- collation() not yet run */ -- the literal '\0' check reads as a bit magical otherwise, but maybe you are doing that to have same comment throughout. Regards, Ayush --0000000000002c0de30651d30021 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

On Fri, 15 May 2= 026 at 03:30, Jeff Davis <pgsql@j-d= avis.com> wrote:
On Fri, 2026-04-24 at 15:44 -0700, Jeff Davis wrote:
> Not known to be reachable after dbf217c1c7, but defend against
> similar
> issues in the future. For instance, an extension might encounter the > problem by calling pg_newlocale_from_collation(DEFAULT_COLLATION_OID)<= br> > from _PG_init(), and end up with a NULL pointer dereference.
>
> Backport through 17, though patch is different in 17 (also attached).<= br>
I plan to commit and backport this soon.


The patch looks good to me as it is.

Just on= e nit in PG 17 patch:

=C2=A0 =C2=A0The provider =3D=3D '\0' = sentinel is correct (valid
=C2=A0 =C2=A0providers are 'b'/'c= '/'i'/'d', all nonzero) and the three guarded
=C2=A0= =C2=A0sites (lc_collate_is_c, lc_ctype_is_c, pg_newlocale_from_collation)<= br>=C2=A0 =C2=A0cover the direct consumers symmetrically.=C2=A0 The only th= ing maybe
=C2=A0 =C2=A0consider is replacing the bare /* should not happ= en */ above the
=C2=A0 =C2=A0'\0' test with something like /* pr= ovider unset; init_database_-
=C2=A0 =C2=A0collation() not yet run */ --= the literal '\0' check reads as a bit
=C2=A0 =C2=A0magical othe= rwise, but maybe you are doing that to have same
=C2=A0 =C2=A0com= ment throughout.
Regards,
Ay= ush
--0000000000002c0de30651d30021--