From 48d395aed17714fb3b3fdab6523f38d596522495 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Penna Date: Thu, 12 Nov 2026 04:21:14 -0800 Subject: [PATCH 1/2] tests: outgrow the pipe that uutils' head grows On Ubuntu 26.04, head is uutils' head, and `head -c N` grows its output pipe to N bytes, up to 1 MiB, before it copies them. Three tests have `head -c` write more than a pipe of the default 64 KiB holds, expecting it to block until the reader takes some: - guest::exec::tests::a_stalled_sink_stalls_only_its_own_execution_and_loses_nothing wrote 256 KiB, which its grown pipe held whole, so head ended, its standard error closed, and the stalled execution had an event to report. It failed on every ubuntu-latest runner once that label moved to Ubuntu 26.04. - guest::exec::tests::cancellation_ends_a_stalled_program_and_the_caller_discards_the_rest wrote 256 KiB after 4 KiB, which still overfills a pipe grown to 256 KiB, but which a head that grows it more would not. - guest::managed_agent::dispatch::tests::output_beyond_the_cap_ends_the_workload_after_the_reads_that_fit wrote 1.5 MiB, of which a grown pipe holds 1 MiB, so head could end and the workload leave its marker once the agent had read 0.5 MiB, before the agent read beyond its 1 MiB cap and ended the workload. Each now writes more than a pipe holds even once the program grows it: 4 MiB in the exec tests, and 3 MiB in the dispatch test, which head can finish only once the agent has read 2 MiB. This ports aa144f7c091 of feature/nvx-refactor (#1535) to dev, whose three tests were the same. On dev, the first failed the same way, at src/guest/exec/tests.rs:318, in the nvx-rs / ubuntu-latest job of run 43269651949 on the ubuntu-26.04 image. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- nvx-rs/src/guest/exec/tests.rs | 13 +++++++++++-- nvx-rs/src/guest/managed_agent/dispatch/tests.rs | 6 ++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/nvx-rs/src/guest/exec/tests.rs b/nvx-rs/src/guest/exec/tests.rs index 5eddf1a0a..d17c6c623 100644 --- a/nvx-rs/src/guest/exec/tests.rs +++ b/nvx-rs/src/guest/exec/tests.rs @@ -38,6 +38,12 @@ const PATIENCE: Duration = Duration::from_secs(20); /// the execution, and the allowance that they grant each stream at a time. const MAX_EVENT_BYTES: usize = 4096; +/// More bytes than a program's output pipe can hold, even after the program grows the pipe, as +/// uutils' `head -c` (Ubuntu 26.04's `head`) does to fit what it copies. Without privileges, a +/// program can grow a pipe to `/proc/sys/fs/pipe-max-size` at most, 1 MiB by default, and uutils +/// grows it to 1 MiB at most. +const MORE_THAN_A_PIPE_HOLDS: usize = 4 * 1024 * 1024; + /// Spawns `command` with new pipes, its standard input piped if `input`, in a process group of /// its own, and starts its execution with `options`. fn start(command: Command, input: bool, options: Options) -> Execution { @@ -288,7 +294,7 @@ fn concurrent_executions_progress_independently() { #[test] fn a_stalled_sink_stalls_only_its_own_execution_and_loses_nothing() { - const LENGTH: usize = 256 * 1024; + const LENGTH: usize = MORE_THAN_A_PIPE_HOLDS; let mut stalled = start( shell(&format!("head -c {LENGTH} /dev/zero")), false, @@ -337,7 +343,10 @@ fn a_stalled_sink_stalls_only_its_own_execution_and_loses_nothing() { fn cancellation_ends_a_stalled_program_and_the_caller_discards_the_rest() { // The program fills its pipe with the first page, which any pipe holds, before it says so. let mut execution = start( - shell("head -c 4096 /dev/zero; printf ready >&2; exec head -c 262144 /dev/zero"), + shell(&format!( + "head -c 4096 /dev/zero; printf ready >&2; \ + exec head -c {MORE_THAN_A_PIPE_HOLDS} /dev/zero" + )), true, Options::new(), ); diff --git a/nvx-rs/src/guest/managed_agent/dispatch/tests.rs b/nvx-rs/src/guest/managed_agent/dispatch/tests.rs index fa1f74019..881b2c5dc 100644 --- a/nvx-rs/src/guest/managed_agent/dispatch/tests.rs +++ b/nvx-rs/src/guest/managed_agent/dispatch/tests.rs @@ -1375,12 +1375,14 @@ fn output_beyond_the_cap_ends_the_workload_after_the_reads_that_fit() -> TestRes let (temporary, mut harness) = direct_harness(); // As the C agent did, the agent forwards each read of up to 32 KiB while the output // stays within 1 MiB, and ends the workload at the first read beyond it, before the - // workload could leave its marker. + // workload could leave its marker. The workload writes 3 MiB into a pipe that holds 1 MiB + // at most, even after uutils' `head -c` (Ubuntu 26.04's `head`) grows it to fit what it + // copies, so it can finish only after the agent has read 2 MiB. let chunk = 32 * 1024; let marker = temporary.path().join("survived"); let script = format!( "head -c {} /dev/zero; touch '{}'", - protocol::MAX_OUTPUT_BYTES + protocol::MAX_OUTPUT_BYTES / 2, + 3 * protocol::MAX_OUTPUT_BYTES, marker.display() ); let mut replies = harness.request_all( From 90cbd4554ac58067ea83510cb07b6a97ecd2115b Mon Sep 17 00:00:00 2001 From: Pedro Henrique Penna Date: Thu, 12 Nov 2026 04:21:14 -0800 Subject: [PATCH 2/2] tests: run the leaked-OpenVMM stand-in as Python test_linux_runners_terminate_openvmm_left_by_earlier_jobs copied sleep to a uniquely named stand-in, which the step under test finds by its process name. On Ubuntu 26.04, sleep is uutils' multi-call coreutils, which picks its program by the name of the file that it runs, so the stand-in ended at once with "coreutils: unknown program 'nvx-leak-...'", and the step found nothing to terminate. Running the copy with argv[0] set to sleep doesn't help: uutils' glibc build, which Ubuntu ships, takes the path that the kernel ran (AT_EXECFN) over argv[0]. The stand-in is now a link to the Python interpreter, named for the stand-in, that sleeps: the kernel names the process after the link, and Python runs under any name. The test expects the step to print that command line. This ports 35af82af156 of feature/nvx-refactor (#1535) to dev, whose test was the same. On dev, it failed the same way, with "coreutils: unknown program 'nvx-leak-2581'", in the NVX CLI / Linux job of run 43269651949 on the ubuntu-26.04 image. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- scripts/test_nvx_tools.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/test_nvx_tools.py b/scripts/test_nvx_tools.py index ca2c3729d..de16efcaa 100644 --- a/scripts/test_nvx_tools.py +++ b/scripts/test_nvx_tools.py @@ -11472,16 +11472,18 @@ def test_linux_runners_terminate_openvmm_left_by_earlier_jobs(self): self.assertIn("\nname=openvmm\n", script) if sys.platform != "linux": return - sleep = shutil.which("sleep") - if sleep is None: - self.skipTest("needs sleep") with tempfile.TemporaryDirectory() as temporary: # A uniquely named stand-in, so that the test never ends a real - # OpenVMM of the account that runs it. + # OpenVMM of the account that runs it: Python, through a link + # with the stand-in's name, since the kernel names a process after + # the file that it runs. A copy of sleep would not do: a + # multi-call coreutils, such as Ubuntu 26.04's, knows no program + # by that name. stand_in = f"nvx-leak-{os.getpid() % 100000}" executable = Path(temporary) / stand_in - shutil.copy(sleep, executable) + executable.symlink_to(sys.executable) + sleeper = [str(executable), "-c", "import time; time.sleep(300)"] check = script.replace("\nname=openvmm\n", f"\nname={stand_in}\n", 1) def run( @@ -11498,13 +11500,9 @@ def run( # The second stand-in ignores SIGTERM, which leaves SIGKILL. for command, status in ( - ([str(executable), "300"], -signal.SIGTERM), + (sleeper, -signal.SIGTERM), ( - [ - "bash", - "-c", - f"trap '' TERM; exec {shlex.quote(str(executable))} 300", - ], + ["bash", "-c", f"trap '' TERM; exec {shlex.join(sleeper)}"], -signal.SIGKILL, ), ): @@ -11532,7 +11530,9 @@ def run( self.assertIn( ", which an earlier job left running\n", result.stdout ) - self.assertIn(f" command: {executable} 300\n", result.stdout) + self.assertIn( + f" command: {' '.join(sleeper)}\n", result.stdout + ) self.assertEqual(leaked.returncode, status) finally: if leaked.poll() is None: @@ -11540,7 +11540,7 @@ def run( leaked.wait() # A zombie has already exited and its parent reaps it, and without # a leftover process, the step says nothing. - zombie = subprocess.Popen([executable, "300"]) + zombie = subprocess.Popen(sleeper) try: zombie.kill() stat = Path(f"/proc/{zombie.pid}/stat")