From 5e603d6c8fe8a3bbd95a4cfd09e37841160dbe23 Mon Sep 17 00:00:00 2001 From: Sam James Date: Fri, 10 Apr 2026 03:29:47 +0100 Subject: [PATCH] dev-libs/glib: fix UB w/ const attribute This broke glib with GCC 16. Closes: https://bugs.gentoo.org/970774 Signed-off-by: Sam James --- .../glib-2.84.4-fix-const-attribute.patch | 99 +++++++++++++++++++ ...2.84.4-r4.ebuild => glib-2.84.4-r5.ebuild} | 1 + ...ib-2.86.5.ebuild => glib-2.86.5-r1.ebuild} | 1 + ...ib-2.88.0.ebuild => glib-2.88.0-r1.ebuild} | 1 + 4 files changed, 102 insertions(+) create mode 100644 dev-libs/glib/files/glib-2.84.4-fix-const-attribute.patch rename dev-libs/glib/{glib-2.84.4-r4.ebuild => glib-2.84.4-r5.ebuild} (99%) rename dev-libs/glib/{glib-2.86.5.ebuild => glib-2.86.5-r1.ebuild} (99%) rename dev-libs/glib/{glib-2.88.0.ebuild => glib-2.88.0-r1.ebuild} (99%) diff --git a/dev-libs/glib/files/glib-2.84.4-fix-const-attribute.patch b/dev-libs/glib/files/glib-2.84.4-fix-const-attribute.patch new file mode 100644 index 0000000000000..a8ddf97c35a53 --- /dev/null +++ b/dev-libs/glib/files/glib-2.84.4-fix-const-attribute.patch @@ -0,0 +1,99 @@ +https://bugs.gentoo.org/970774 +https://gitlab.gnome.org/GNOME/glib/-/merge_requests/5145 + +From 9f5903a96f419058d457de7b7544c2bc9e73e510 Mon Sep 17 00:00:00 2001 +From: Sam James +Date: Fri, 10 Apr 2026 02:28:48 +0100 +Subject: [PATCH] gvarianttype: use pure attribute, not inappropriate const + +As found in https://gcc.gnu.org/PR124837, it is wrong to use the const +attribute [0] for g_variant_type_*is* because it may be called repeatedly +with different pointed-to data. The pure attribute [1] is what we want +here because it allows pointed-to data to change, so change to that. + +const would be OK here if it pointed to a constant buffer, but it doesn't, +it points to newly malloc'd memory from all over the place. + +[0] https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Common-Function-Attributes.html#index-const-function-attribute +[1] https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Common-Function-Attributes.html#index-pure-function-attribute + +Fixes: 49bfa7b9cf8b16f7f6a5b1db565575d61a37100f +Signed-off-by: Sam James +--- + glib/gvarianttype.h | 32 ++++++++++++++++---------------- + 1 file changed, 16 insertions(+), 16 deletions(-) + +diff --git a/glib/gvarianttype.h b/glib/gvarianttype.h +index 38980af829..3a57b9131a 100644 +--- a/glib/gvarianttype.h ++++ b/glib/gvarianttype.h +@@ -302,7 +302,7 @@ typedef struct _GVariantType GVariantType; + + /* type string checking */ + GLIB_AVAILABLE_IN_ALL +-gboolean g_variant_type_string_is_valid (const gchar *type_string) G_GNUC_CONST; ++gboolean g_variant_type_string_is_valid (const gchar *type_string) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL + gboolean g_variant_type_string_scan (const gchar *string, + const gchar *limit, +@@ -326,21 +326,21 @@ gchar * g_variant_type_dup_string (const G + + /* classification */ + GLIB_AVAILABLE_IN_ALL +-gboolean g_variant_type_is_definite (const GVariantType *type) G_GNUC_CONST; ++gboolean g_variant_type_is_definite (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-gboolean g_variant_type_is_container (const GVariantType *type) G_GNUC_CONST; ++gboolean g_variant_type_is_container (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-gboolean g_variant_type_is_basic (const GVariantType *type) G_GNUC_CONST; ++gboolean g_variant_type_is_basic (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-gboolean g_variant_type_is_maybe (const GVariantType *type) G_GNUC_CONST; ++gboolean g_variant_type_is_maybe (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-gboolean g_variant_type_is_array (const GVariantType *type) G_GNUC_CONST; ++gboolean g_variant_type_is_array (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-gboolean g_variant_type_is_tuple (const GVariantType *type) G_GNUC_CONST; ++gboolean g_variant_type_is_tuple (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-gboolean g_variant_type_is_dict_entry (const GVariantType *type) G_GNUC_CONST; ++gboolean g_variant_type_is_dict_entry (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-gboolean g_variant_type_is_variant (const GVariantType *type) G_GNUC_CONST; ++gboolean g_variant_type_is_variant (const GVariantType *type) G_GNUC_PURE; + + /* for hash tables */ + GLIB_AVAILABLE_IN_ALL +@@ -352,21 +352,21 @@ gboolean g_variant_type_equal (gconstp + /* subtypes */ + GLIB_AVAILABLE_IN_ALL + gboolean g_variant_type_is_subtype_of (const GVariantType *type, +- const GVariantType *supertype) G_GNUC_CONST; ++ const GVariantType *supertype) G_GNUC_PURE; + + /* type iterator interface */ + GLIB_AVAILABLE_IN_ALL +-const GVariantType * g_variant_type_element (const GVariantType *type) G_GNUC_CONST; ++const GVariantType * g_variant_type_element (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-const GVariantType * g_variant_type_first (const GVariantType *type) G_GNUC_CONST; ++const GVariantType * g_variant_type_first (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-const GVariantType * g_variant_type_next (const GVariantType *type) G_GNUC_CONST; ++const GVariantType * g_variant_type_next (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-gsize g_variant_type_n_items (const GVariantType *type) G_GNUC_CONST; ++gsize g_variant_type_n_items (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-const GVariantType * g_variant_type_key (const GVariantType *type) G_GNUC_CONST; ++const GVariantType * g_variant_type_key (const GVariantType *type) G_GNUC_PURE; + GLIB_AVAILABLE_IN_ALL +-const GVariantType * g_variant_type_value (const GVariantType *type) G_GNUC_CONST; ++const GVariantType * g_variant_type_value (const GVariantType *type) G_GNUC_PURE; + + /* constructors */ + GLIB_AVAILABLE_IN_ALL +-- +GitLab diff --git a/dev-libs/glib/glib-2.84.4-r4.ebuild b/dev-libs/glib/glib-2.84.4-r5.ebuild similarity index 99% rename from dev-libs/glib/glib-2.84.4-r4.ebuild rename to dev-libs/glib/glib-2.84.4-r5.ebuild index 84454b7eb57ab..9193a315362e8 100644 --- a/dev-libs/glib/glib-2.84.4-r4.ebuild +++ b/dev-libs/glib/glib-2.84.4-r5.ebuild @@ -97,6 +97,7 @@ PATCHES=( "${FILESDIR}"/${PN}-2.86-MR-4934-CVE-2025-14087.patch "${FILESDIR}"/${PN}-2.86-MR-4936.patch "${FILESDIR}"/${PN}-2.84.4-setlocale-glibc-2.43.patch + "${FILESDIR}"/${PN}-2.84.4-fix-const-attribute.patch ) python_check_deps() { diff --git a/dev-libs/glib/glib-2.86.5.ebuild b/dev-libs/glib/glib-2.86.5-r1.ebuild similarity index 99% rename from dev-libs/glib/glib-2.86.5.ebuild rename to dev-libs/glib/glib-2.86.5-r1.ebuild index 58c2c4c26cce0..79af0bddbc7bf 100644 --- a/dev-libs/glib/glib-2.86.5.ebuild +++ b/dev-libs/glib/glib-2.86.5-r1.ebuild @@ -92,6 +92,7 @@ MULTILIB_CHOST_TOOLS=( PATCHES=( "${FILESDIR}"/${PN}-2.64.1-mark-gdbus-server-auth-test-flaky.patch "${FILESDIR}"/${PN}-2.84.4-setlocale-glibc-2.43.patch + "${FILESDIR}"/${PN}-2.84.4-fix-const-attribute.patch ) python_check_deps() { diff --git a/dev-libs/glib/glib-2.88.0.ebuild b/dev-libs/glib/glib-2.88.0-r1.ebuild similarity index 99% rename from dev-libs/glib/glib-2.88.0.ebuild rename to dev-libs/glib/glib-2.88.0-r1.ebuild index 80dfab5ac6286..2998430263bba 100644 --- a/dev-libs/glib/glib-2.88.0.ebuild +++ b/dev-libs/glib/glib-2.88.0-r1.ebuild @@ -91,6 +91,7 @@ MULTILIB_CHOST_TOOLS=( PATCHES=( "${FILESDIR}"/${PN}-2.64.1-mark-gdbus-server-auth-test-flaky.patch + "${FILESDIR}"/${PN}-2.84.4-fix-const-attribute.patch ) python_check_deps() {