public inbox for [email protected]
help / color / mirror / Atom feedFrom: Jeff Davis <[email protected]>
To: [email protected]
Subject: Add a guard against uninitialized default locale
Date: Fri, 24 Apr 2026 15:44:23 -0700
Message-ID: <[email protected]> (raw)
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).
Regards,
Jeff Davis
Attachments:
[text/x-patch] v1.19-0001-Guard-against-uninitialized-default-locale.patch (958B, 2-v1.19-0001-Guard-against-uninitialized-default-locale.patch)
download | inline diff:
From 025a759ff37046dac7864bedc16fcf0b1d1ae9b8 Mon Sep 17 00:00:00 2001
From: Jeff Davis <[email protected]>
Date: Wed, 22 Apr 2026 15:09:27 -0700
Subject: [PATCH v1.19] Guard against uninitialized default locale.
No known problem today, but defend against issues like dbf217c1c7 in
the future.
Backpatch-through: 17
---
src/backend/utils/adt/pg_locale.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 6c5c1019e1e..7cd1a060759 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -1192,7 +1192,13 @@ pg_newlocale_from_collation(Oid collid)
bool found;
if (collid == DEFAULT_COLLATION_OID)
+ {
+ /* should not happen */
+ if (default_locale == NULL)
+ elog(ERROR, "default locale not initialized");
+
return default_locale;
+ }
/*
* Some callers expect C_COLLATION_OID to succeed even without catalog
--
2.43.0
[text/x-patch] v1.17-0001-Guard-against-uninitialized-default-locale.patch (1.5K, 3-v1.17-0001-Guard-against-uninitialized-default-locale.patch)
download | inline diff:
From 4d4c837371fc66850b9499d30dcad43b1f5a764d Mon Sep 17 00:00:00 2001
From: Jeff Davis <[email protected]>
Date: Wed, 22 Apr 2026 15:09:27 -0700
Subject: [PATCH v1.17] Guard against uninitialized default locale.
No known problem today, but defend against issues like dbf217c1c7 in
the future.
Backpatch-through: 17
---
src/backend/utils/adt/pg_locale.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index aa0114ce120..7a51b953f0a 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -1361,6 +1361,10 @@ lc_collate_is_c(Oid collation)
if (result >= 0)
return (bool) result;
+ /* should not happen */
+ if (default_locale.provider == '\0')
+ elog(ERROR, "default locale not initialized");
+
if (default_locale.provider == COLLPROVIDER_BUILTIN)
{
result = true;
@@ -1428,6 +1432,10 @@ lc_ctype_is_c(Oid collation)
if (result >= 0)
return (bool) result;
+ /* should not happen */
+ if (default_locale.provider == '\0')
+ elog(ERROR, "default locale not initialized");
+
if (default_locale.provider == COLLPROVIDER_BUILTIN)
{
localeptr = default_locale.info.builtin.locale;
@@ -1586,6 +1594,10 @@ pg_newlocale_from_collation(Oid collid)
if (collid == DEFAULT_COLLATION_OID)
{
+ /* should not happen */
+ if (default_locale.provider == '\0')
+ elog(ERROR, "default locale not initialized");
+
if (default_locale.provider == COLLPROVIDER_LIBC)
return (pg_locale_t) 0;
else
--
2.43.0
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: Add a guard against uninitialized default locale
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox