[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/17: gnu: glib: Fix build with glibc 2.38.
From: |
guix-commits |
Subject: |
07/17: gnu: glib: Fix build with glibc 2.38. |
Date: |
Thu, 18 Jan 2024 07:58:11 -0500 (EST) |
jpoiret pushed a commit to branch core-updates
in repository guix.
commit 403ff7ecbbcc777ecb093d0f50bfa984fc148344
Author: Josselin Poiret <dev@jpoiret.xyz>
AuthorDate: Fri Jan 12 10:54:49 2024 +0100
gnu: glib: Fix build with glibc 2.38.
* gnu/packages/patches/glib-gerror-null-format.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/glib.scm (glib-next): Use it.
Change-Id: I5bef91009b79a990f9f38b72e4168e9605281be8
---
gnu/local.mk | 1 +
gnu/packages/glib.scm | 6 +-
gnu/packages/patches/glib-gerror-null-format.patch | 137 +++++++++++++++++++++
3 files changed, 143 insertions(+), 1 deletion(-)
diff --git a/gnu/local.mk b/gnu/local.mk
index a22065630b..6affc9895d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1315,6 +1315,7 @@ dist_patch_DATA =
\
%D%/packages/patches/gitg-fix-positional-argument.patch \
%D%/packages/patches/gklib-suitesparse.patch \
%D%/packages/patches/glib-appinfo-watch.patch \
+ %D%/packages/patches/glib-gerror-null-format.patch \
%D%/packages/patches/glib-networking-disable-connection-tls1.2-test.patch
\
%D%/packages/patches/glib-networking-gnutls-binding.patch \
%D%/packages/patches/glib-skip-failing-test.patch \
diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 13f957f810..2cbb4bdcb7 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -501,7 +501,11 @@ functions for strings and common data structures.")
'(substitute* "glib/tests/spawn-test.c"
(("/bin/sh") "sh")))
(sha256
- (base32 "1bgfch7zj1pq4rkqcibfky1470ijljyrx5pn5s5v9mk72s22n6nz"))))
+ (base32 "1bgfch7zj1pq4rkqcibfky1470ijljyrx5pn5s5v9mk72s22n6nz"))
+ (patches (append
+ ;; Remove with upgrade to >=2.75.4
+ (search-patches "glib-gerror-null-format.patch")
+ (origin-patches (package-source glib))))))
(arguments
(substitute-keyword-arguments (package-arguments glib)
((#:test-options test-options ''())
diff --git a/gnu/packages/patches/glib-gerror-null-format.patch
b/gnu/packages/patches/glib-gerror-null-format.patch
new file mode 100644
index 0000000000..3b1f0dc582
--- /dev/null
+++ b/gnu/packages/patches/glib-gerror-null-format.patch
@@ -0,0 +1,137 @@
+From c4203f740ced1f1fc576caf1550441b57107fd00 Mon Sep 17 00:00:00 2001
+From: Philip Withnall <pwithnall@endlessos.org>
+Date: Mon, 20 Feb 2023 16:41:23 +0000
+Subject: [PATCH] gerror: Emit a critical warning if the message format is NULL
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The code has warned about this since commit 6d9f874330 in 2011.
+
+glibc 2.37 has just started asserting if a `NULL` format is passed to
+`sprintf()`, which caused the existing GLib workaround to start
+asserting too.
+
+Bite the bullet and upgrade the warning for `format != NULL` to a
+critical warning. Projects have had 12 years to fix their code.
+
+The original bug reports
+(https://bugzilla.gnome.org/show_bug.cgi?id=660371,
+https://bugzilla.gnome.org/show_bug.cgi?id=560482) are actually both
+about a domain which is `0`, rather than a format which is `NULL`, which
+gives some confidence that this change will actually impact very little
+third party code.
+
+Since it doesn’t currently need changing, I have not touched the warning
+about `domain != 0`.
+
+Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
+
+Fixes: #2913
+---
+ glib/gerror.c | 8 +++++---
+ glib/tests/error.c | 38 +++++++++++++++++++++++---------------
+ 2 files changed, 28 insertions(+), 18 deletions(-)
+
+diff --git a/glib/gerror.c b/glib/gerror.c
+index 61817fa7bc..7ac85fc664 100644
+--- a/glib/gerror.c
++++ b/glib/gerror.c
+@@ -755,13 +755,14 @@ g_error_new_valist (GQuark domain,
+ const gchar *format,
+ va_list args)
+ {
++ g_return_val_if_fail (format != NULL, NULL);
++
+ /* Historically, GError allowed this (although it was never meant to work),
+ * and it has significant use in the wild, which g_return_val_if_fail
+ * would break. It should maybe g_return_val_if_fail in GLib 4.
+ * (GNOME#660371, GNOME#560482)
+ */
+ g_warn_if_fail (domain != 0);
+- g_warn_if_fail (format != NULL);
+
+ return g_error_new_steal (domain, code, g_strdup_vprintf (format, args),
NULL);
+ }
+@@ -887,9 +888,10 @@ g_error_copy (const GError *error)
+ ErrorDomainInfo info;
+
+ g_return_val_if_fail (error != NULL, NULL);
+- /* See g_error_new_valist for why these don't return */
++ g_return_val_if_fail (error->message != NULL, NULL);
++
++ /* See g_error_new_valist for why this doesn’t return */
+ g_warn_if_fail (error->domain != 0);
+- g_warn_if_fail (error->message != NULL);
+
+ copy = g_error_new_steal (error->domain,
+ error->code,
+diff --git a/glib/tests/error.c b/glib/tests/error.c
+index fa3a25969d..8dd40aa566 100644
+--- a/glib/tests/error.c
++++ b/glib/tests/error.c
+@@ -129,17 +129,6 @@ test_new_valist_invalid_va (gpointer dummy,
+ * a %NULL format will crash on FreeBSD as its implementation of vasprintf()
+ * is less forgiving than Linux’s. That’s fine: it’s a programmer error in
+ * either case. */
+- const struct
+- {
+- GQuark domain;
+- const gchar *format;
+- }
+- tests[] =
+- {
+- { G_MARKUP_ERROR, NULL },
+- { 0, "Message" },
+- };
+- gsize i;
+
+ g_test_summary ("Test that g_error_new_valist() rejects invalid input");
+
+@@ -149,12 +138,31 @@ test_new_valist_invalid_va (gpointer dummy,
+ return;
+ }
+
+- for (i = 0; i < G_N_ELEMENTS (tests); i++)
+ {
+- GError *error = NULL, *error_copy = NULL;
++ GError *error = NULL;
+ va_list ap;
+
+- g_test_message ("Test %" G_GSIZE_FORMAT, i);
++ va_start (ap, dummy);
++
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wformat-nonliteral"
++#pragma GCC diagnostic ignored "-Wformat-extra-args"
++
++ g_test_expect_message (G_LOG_DOMAIN,
++ G_LOG_LEVEL_CRITICAL,
++ "*g_error_new_valist: assertion 'format != NULL'
failed*");
++ error = g_error_new_valist (G_MARKUP_ERROR, G_MARKUP_ERROR_EMPTY, NULL,
ap);
++ g_test_assert_expected_messages ();
++ g_assert_null (error);
++
++#pragma GCC diagnostic pop
++
++ va_end (ap);
++ }
++
++ {
++ GError *error = NULL, *error_copy = NULL;
++ va_list ap;
+
+ va_start (ap, dummy);
+
+@@ -164,7 +172,7 @@ test_new_valist_invalid_va (gpointer dummy,
+ g_test_expect_message (G_LOG_DOMAIN,
+ G_LOG_LEVEL_WARNING,
+ "*g_error_new_valist: runtime check failed*");
+- error = g_error_new_valist (tests[i].domain, G_MARKUP_ERROR_EMPTY,
tests[i].format, ap);
++ error = g_error_new_valist (0, G_MARKUP_ERROR_EMPTY, "Message", ap);
+ g_test_assert_expected_messages ();
+ g_assert_nonnull (error);
+
+--
+GitLab
+
- branch core-updates updated (ed07002906 -> a5735488d3), guix-commits, 2024/01/18
- 01/17: gnu: sway: Fix build with newer libinput., guix-commits, 2024/01/18
- 02/17: gnu: zig: Remove unneeded librt patch., guix-commits, 2024/01/18
- 08/17: gnu: liboauth: Use C unicode locale in tests., guix-commits, 2024/01/18
- 07/17: gnu: glib: Fix build with glibc 2.38.,
guix-commits <=
- 03/17: gnu: gpgme: Hardcode gpg binaries' location., guix-commits, 2024/01/18
- 05/17: gnu: docbook2x: Fix build., guix-commits, 2024/01/18
- 04/17: gnu: glib-networking: Disable broken TLS1.2 test., guix-commits, 2024/01/18
- 13/17: gnu: parted: Use C.UTF-8 for Unicode tests., guix-commits, 2024/01/18
- 15/17: gnu: ffmpeg-4: Fix build with binutils ≥ 2.41., guix-commits, 2024/01/18
- 09/17: gnu: python-pillow: Fix build with zlib 1.3., guix-commits, 2024/01/18
- 06/17: gnu: flite: Disable parallel build., guix-commits, 2024/01/18
- 16/17: gnu: python-matplotlib: Fix flaky Legend loc test., guix-commits, 2024/01/18
- 17/17: gnu: evolution-data-server: Use C.UTF-8 locale in test., guix-commits, 2024/01/18
- 11/17: gnu: ghc-9.2: Remove unneeded glibc 2.33 patch., guix-commits, 2024/01/18