glib-2.0: ptest: skip memory-monitor-psi /dev/null test
PATCH 1/1 glib-2.0: ptest: skip memory-monitor-psi /dev/null test
The /memory-monitor-psi-env-set/write-env-null test sets MEMORY_PRESSURE_WATCH=/dev/null and asserts that no low-memory-warning is emitted. That assumption is unsound: GMemoryMonitorPsi polls the watch fd for G_IO_IN and /dev/null is always readable, so the low-memory callback fires and the assertion (warning_level == -1) fails. It reproduces under QEMU system emulation on the autobuilders (qemuarm64), and the resulting abort leaves the mock PSI FIFO behind, cascading into a mkfifo failure in the memory-monitor-psi test.
Add a patch dropping the test (and its now-unused function); the other memory-monitor-psi-env-set subtests still run.
[YOCTO #16464]
--- ...ip-memory-monitor-psi-write-env-null.patch | 88 +++++++++++++++++++ meta/recipes-core/glib-2.0/glib.inc | 1 + 2 files changed, 89 insertions(+) create mode 100644 meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch
meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch new file +88 -0
@@ -0,0 +1,88 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Pratik Farkase <[email protected]> +Date: Mon, 26 Oct 2026 11:55:00 +0000 +Subject: [PATCH] Skip /memory-monitor-psi-env-set/write-env-null test + +test_write_env_null sets MEMORY_PRESSURE_WATCH=/dev/null and asserts +that no low-memory-warning signal is emitted (warning_level stays -1). + +This assumption does not hold. When MEMORY_PRESSURE_WATCH points at an +existing path, GMemoryMonitorPsi opens it with O_RDWR | O_NONBLOCK and +creates a GSource polling for G_IO_IN. /dev/null is always readable +(reads return immediate EOF), so the source is immediately dispatchable, +the low-memory callback fires and warning_level becomes 50, making the +assertion (warning_level == -1) fail: + + GLib-GIO:ERROR:.../gio/tests/memory-monitor-psi-env-set.c:300: + test_write_env_null: assertion failed (warning_level == -1): (50 == -1) + +Whether the spurious event is caught before the monitor is torn down +depends on GMainContext iteration timing, so it only reproduces in +slower environments such as QEMU system emulation on the Yocto +autobuilders (seen on qemuarm64). The test's abort also leaves the mock +PSI FIFO $TMPDIR/cgroup behind, which then makes the separate +memory-monitor-psi test fail in tests_setup with "mkfifo(): File exists". + +Drop the test registration and the now-unused test function. The +remaining memory-monitor-psi-env-set subtests still run. + +https://bugzilla.yoctoproject.org/show_bug.cgi?id=16464 + +Upstream-Status: Inappropriate [upstream ticket: https://gitlab.gnome.org/GNOME/glib/-/work_items/4094] +Signed-off-by: Pratik Farkase <[email protected]> +--- + gio/tests/memory-monitor-psi-env-set.c | 36 -------------------------- + 1 file changed, 36 deletions(-) + +--- a/gio/tests/memory-monitor-psi-env-set.c ++++ b/gio/tests/memory-monitor-psi-env-set.c +@@ -269,39 +269,6 @@ + g_clear_error (&local_error); + } + +-static void +-test_write_env_null (SetupData *setup, gconstpointer data) +-{ +- GMemoryMonitorPsi *monitor; +- unsigned long warning_id; +- int warning_level = -1; +- GError *local_error = NULL; +- +- /* The contents is generated by running "dd if=/dev/random of=/foo/bar bs=128 count=1" */ +- const gchar *env_write = "hVh9eV0BZsh/GWEs9V6zKyO3VUe2MnxTxLZbA7BRo7GJKHAAayIRsgO8EI4m8iFskhx/O4cAfpyL" +- "YQ8LFHMG5XBuBmqD9spZghu0eVYF2X8lCCT+iBlEFw5dWiSa6XwJN++AmHi1tp4uJj0UBR7CwV5c" +- "+ms9ZDUqOQrvlFHUSxw="; +- +- g_setenv ("MEMORY_PRESSURE_WATCH", "/dev/null", TRUE); +- g_setenv ("MEMORY_PRESSURE_WRITE", env_write, TRUE); +- +- monitor = g_object_new (G_TYPE_MEMORY_MONITOR_PSI, +- "proc-path", setup->mock_proc_path, +- NULL); +- warning_id = g_signal_connect (monitor, "low-memory-warning", +- G_CALLBACK (memory_monitor_psi_signal_cb), &warning_level); +- g_initable_init (G_INITABLE (monitor), NULL, &local_error); +- g_assert_no_error (local_error); +- +- g_signal_handler_disconnect (monitor, warning_id); +- g_object_unref (monitor); +- +- /* warning_level shouldn't be set */ +- g_assert_cmpint (warning_level, ==, -1); +- +- g_clear_error (&local_error); +-} +- + static gpointer + test_write_env_unix_domain_socket_thread (gpointer user_data) + { +@@ -395,9 +362,6 @@ + g_test_add ("/memory-monitor-psi-env-set/write-env", SetupData, NULL, + tests_setup, test_write_env, tests_teardown); + +- g_test_add ("/memory-monitor-psi-env-set/write-env-null", SetupData, NULL, +- tests_setup, test_write_env_null, tests_teardown); +- + g_test_add ("/memory-monitor-psi-env-set/write-env-unix-domain-socket", SetupData, NULL, + tests_unix_domain_setup, test_write_env_unix_domain_socket, tests_unix_domain_teardown); +
meta/recipes-core/glib-2.0/glib.inc +1 -0
@@ -235,6 +235,7 @@ SRC_URI += "file://run-ptest \ file://0010-Do-not-hardcode-python-path-into-various-tools.patch \ file://skip-timeout.patch \ file://skip-monotonic-time-similar.patch \ + file://skip-memory-monitor-psi-write-env-null.patch \ " SRC_URI:append:class-native = " file://relocate-modules.patch \ file://0001-meson.build-do-not-enable-pidfd-features-on-native-g.patch \
Signature · 1 line
2.43.0
Quoted 92 lines · Pratik Farkase
The /memory-monitor-psi-env-set/write-env-null test sets MEMORY_PRESSURE_WATCH=/dev/null and asserts that no low-memory-warning is emitted. That assumption is unsound: GMemoryMonitorPsi polls the watch fd for
G_IO_INand/dev/nullis always readable, so the low-memory callback fires and the assertion (warning_level== -1) fails. It reproduces under QEMU system emulation on the autobuilders (qemuarm64), and the resulting abort leaves the mock PSI FIFO behind, cascading into a mkfifo failure in the memory-monitor-psi test.Add a patch dropping the test (and its now-unused function); the other memory-monitor-psi-env-set subtests still run.
[YOCTO #16464]
Signed-off-by Pratik Farkase <[email protected]>--- ...ip-memory-monitor-psi-write-env-null.patch | 88 +++++++++++++++++++ meta/recipes-core/glib-2.0/glib.inc | 1 + 2 files changed, 89 insertions(+) create mode 100644 meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patchmeta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch new file +65
-0@@ -0,0 +1,88 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Pratik Farkase <[email protected]> +Date: Mon, 26 Oct 2026 11:55:00 +0000 +Subject: [PATCH] Skip /memory-monitor-psi-env-set/write-env-null test + +test_write_env_null sets MEMORY_PRESSURE_WATCH=/dev/null and asserts +that no low-memory-warning signal is emitted (warning_level stays -1). + +This assumption does not hold. When MEMORY_PRESSURE_WATCH points at an +existing path, GMemoryMonitorPsi opens it with O_RDWR | O_NONBLOCK and +creates a GSource polling for G_IO_IN. /dev/null is always readable +(reads return immediate EOF), so the source is immediately dispatchable, +the low-memory callback fires and warning_level becomes 50, making the +assertion (warning_level == -1) fail: + + GLib-GIO:ERROR:.../gio/tests/memory-monitor-psi-env-set.c:300: + test_write_env_null: assertion failed (warning_level == -1): (50 == -1) + +Whether the spurious event is caught before the monitor is torn down +depends on GMainContext iteration timing, so it only reproduces in +slower environments such as QEMU system emulation on the Yocto +autobuilders (seen on qemuarm64). The test's abort also leaves the mock +PSI FIFO $TMPDIR/cgroup behind, which then makes the separate +memory-monitor-psi test fail in tests_setup with "mkfifo(): File exists". + +Drop the test registration and the now-unused test function. The +remaining memory-monitor-psi-env-set subtests still run. + +https://bugzilla.yoctoproject.org/show_bug.cgi?id=16464 + +Upstream-Status: Inappropriate [upstream ticket: https://gitlab.gnome.org/GNOME/glib/-/work_items/4094] +Signed-off-by: Pratik Farkase <[email protected]> +--- + gio/tests/memory-monitor-psi-env-set.c | 36 -------------------------- + 1 file changed, 36 deletions(-) + +--- a/gio/tests/memory-monitor-psi-env-set.c ++++ b/gio/tests/memory-monitor-psi-env-set.c +@@ -269,39 +269,6 @@ + g_clear_error (&local_error); + } + +-static void +-test_write_env_null (SetupData *setup, gconstpointer data) +-{ +- GMemoryMonitorPsi *monitor; +- unsigned long warning_id; +- int warning_level = -1; +- GError *local_error = NULL; +- +- /* The contents is generated by running "dd if=/dev/random of=/foo/bar bs=128 count=1" */ +- const gchar *env_write = "hVh9eV0BZsh/GWEs9V6zKyO3VUe2MnxTxLZbA7BRo7GJKHAAayIRsgO8EI4m8iFskhx/O4cAfpyL" +- "YQ8LFHMG5XBuBmqD9spZghu0eVYF2X8lCCT+iBlEFw5dWiSa6XwJN++AmHi1tp4uJj0UBR7CwV5c" +- "+ms9ZDUqOQrvlFHUSxw="; +- +- g_setenv ("MEMORY_PRESSURE_WATCH", "/dev/null", TRUE); +- g_setenv ("MEMORY_PRESSURE_WRITE", env_write, TRUE); +- +- monitor = g_object_new (G_TYPE_MEMORY_MONITOR_PSI, +- "proc-path", setup->mock_proc_path, +- NULL); +- warning_id = g_signal_connect (monitor, "low-memory-warning", +- G_CALLBACK (memory_monitor_psi_signal_cb), &warning_level); +- g_initable_init (G_INITABLE (monitor), NULL, &local_error); +- g_assert_no_error (local_error);
meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch line 75
Quoted 10 lines
meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch new file +10
-0+- +- g_signal_handler_disconnect (monitor, warning_id); +- g_object_unref (monitor); +- +- /* warning_level shouldn't be set */ +- g_assert_cmpint (warning_level, ==, -1); +- +- g_clear_error (&local_error); +-} +-
Hi Pratik,
The other patches for glib-2.0 do not remove the actual test function, just the g_test_add() call below. That is preferred as the diff is smaller and so there will be less need to rebase as we update to future releases. Could you send a v2 which just does that?
meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch line 88
Quoted 13 lines
meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch new file +13
-0+ static gpointer + test_write_env_unix_domain_socket_thread (gpointer user_data) + { +@@ -395,9 +362,6 @@ + g_test_add ("/memory-monitor-psi-env-set/write-env", SetupData, NULL, + tests_setup, test_write_env, tests_teardown); + +- g_test_add ("/memory-monitor-psi-env-set/write-env-null", SetupData, NULL, +- tests_setup, test_write_env_null, tests_teardown); +- + g_test_add ("/memory-monitor-psi-env-set/write-env-unix-domain-socket", SetupData, NULL, + tests_unix_domain_setup, test_write_env_unix_domain_socket, tests_unix_domain_teardown); +
Best regards,
Signature · 1 line
Paul Barker