Openembedded Core Discussions
 help / color / mirror / Atom feed
* [OE-core][PATCH] glib-2.0: ptest: skip memory-monitor-psi /dev/null test
@ 2026-10-26 12:14 Pratik Farkase
  2026-11-05 14:51 ` Paul Barker
  0 siblings, 1 reply; 2+ messages in thread
From: Pratik Farkase @ 2026-10-26 12:14 UTC (permalink / raw)
  To: openembedded-core; +Cc: pratik.farkase, 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_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]

Signed-off-by: Pratik Farkase <pratik.farkase@est.tech>
---
 ...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

diff --git a/meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch b/meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch
new file mode 100644
index 0000000000..aa9ef919df
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch
@@ -0,0 +1,88 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Pratik Farkase <pratik.farkase@est.tech>
+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 <pratik.farkase@est.tech>
+---
+ 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);
+ 
diff --git a/meta/recipes-core/glib-2.0/glib.inc b/meta/recipes-core/glib-2.0/glib.inc
index 91c9795547..eee9185c70 100644
--- a/meta/recipes-core/glib-2.0/glib.inc
+++ b/meta/recipes-core/glib-2.0/glib.inc
@@ -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 \
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [OE-core][PATCH] glib-2.0: ptest: skip memory-monitor-psi /dev/null test
  2026-10-26 12:14 [OE-core][PATCH] glib-2.0: ptest: skip memory-monitor-psi /dev/null test Pratik Farkase
@ 2026-11-05 14:51 ` Paul Barker
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Barker @ 2026-11-05 14:51 UTC (permalink / raw)
  To: Pratik Farkase, openembedded-core; +Cc: pratik.farkase

On Mon Oct 26, 2026 at 12:14 PM GMT, Pratik Farkase wrote:
> 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]
>
> Signed-off-by: Pratik Farkase <pratik.farkase@est.tech>
> ---
>  ...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
>
> diff --git a/meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch b/meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch
> new file mode 100644
> index 0000000000..aa9ef919df
> --- /dev/null
> +++ b/meta/recipes-core/glib-2.0/files/skip-memory-monitor-psi-write-env-null.patch
> @@ -0,0 +1,88 @@
> +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
> +From: Pratik Farkase <pratik.farkase@est.tech>
> +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 <pratik.farkase@est.tech>
> +---
> + 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);
> +-}
> +-

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?

> + 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,

-- 
Paul Barker


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-05 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-26 12:14 [OE-core][PATCH] glib-2.0: ptest: skip memory-monitor-psi /dev/null test Pratik Farkase
2026-11-05 14:51 ` Paul Barker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox