8000 test(runtime-holder): read only this process from the kernel's list when testing running builds by inkless · Pull Request #409 · inkless/bazhen · GitHub
[go: up one dir, main page]

Skip to content

test(runtime-holder): read only this process from the kernel's list when testing running builds - #409

Open
inkless wants to merge 1 commit into
mainfrom
gz/bz-409-flake-install-running-builds-test-on-macos
Open

inkless wants to merge 1 commit into
mainfrom
gz/bz-409-flake-install-running-builds-test-on-macos

Conversation

@inkless
@inkless inkless commented Nov 22, 2026
Copy link
Copy Markdown
Owner

What

install::tests::are_read_from_the_kernel_which_lists_this_process failed once on rust (macos) with left: None, right: Some({}). It called the real running_builds over a fresh, empty holder directory, so its answer depended on every process the runner's user had, not only on what the test sets up.

The test now hands running_builds_with the kernel's real list (process::pids()) kept to this process's pid, with the real reader (seen). It still fails if the list can't be read, doesn't show this process, or the reader misreads this process's owner or arguments. It reads no other process, and it spawns and signals nothing, so it stays a host test. Test-only change; no production code moves.

Why None is right, and production stays as it is

running_builds returns None when any listed process of this user reads back with an owner (Seen::Unknown) or arguments (Seen::Of { argv: None }) that can't be read. None makes prune_unused_with remove nothing. Its only caller is the daemon's start (install in crates/bazhen-daemon/src/holder.rs).

A process of this user whose arguments can't be read might be a holder running an old build. The module's invariant is that a build goes only once no process of this user runs it. Skipping such a process could delete a live holder's build. Giving up costs only that old builds wait for the next daemon start. A retry would narrow the race, not remove it. So fail-closed is deliberate. It is pinned by install::tests::are_unknown_when_a_process_of_this_user_s_arguments_can_t_be_read_and_then_none_go (and, for an unreadable owner, takes_a_process_for_gone_or_another_s_only_when_the_kernel_says_so_and_else_knows_nothing). Please don't "fix" this by having running_builds skip unreadable processes.

What made it None on the runner: not confirmed

The CI log doesn't say which process read back unreadable, so this part is unconfirmed:

  • It isn't a zombie. On macOS the owner is read through proc_pidinfo(PROC_PIDT_SHORTBSDINFO), which answers ESRCH for a zombie, and seen_by maps ESRCH to Seen::Gone.
  • The likely window is a process of this user that is exiting (not yet a zombie) or mid-exec. For such a process proc_pidinfo still answers but KERN_PROCARGS2 fails, and start_time::of doesn't yet say it's absent.
  • KERN_PROC_ALL growing past its four tries would also give None.

The fix doesn't depend on which of these it was: each lies outside what the test controls.

Verification

  • moon run :test-rust -- install::tests: 25 passed.
  • Hand controls, each failing on the test's assertion with left: None, right: Some({}), then restored (recorded as Control: trailers on the commit):
    • listed_me |= false in running_builds_with
    • seen_by answering argv: None for a readable process
  • moon run :check: CHECK_EXIT=0.

Self-review tier: none. This is a small, test-only change in one function; an independent review follows.

🤖 Generated with Claude Code

@inkless
inkless force-pushed the gz/bz-409-flake-install-running-builds-test-on-macos branch from 8fe49d7 to 3f90336 Compare November 22, 2026 23:13
…hen testing running builds

are_read_from_the_kernel_which_lists_this_process asked the real running_builds for a fresh,
empty directory and expected Some({}). That answer depends on every process the runner's user
has: running_builds rightly gives up when any of them reads back with an owner or arguments that
can't be read, and on a shared macOS runner nextest's own test processes start and exit around
it. It failed once that way, left: None.

The test now hands running_builds_with the kernel's real list, kept to this process, and the
real reader. It still fails if the list can't be read, doesn't show this process, or the reader
misreads its owner or arguments. Production is unchanged.

Control: install::tests::are_read_from_the_kernel_which_lists_this_process: listed_me |= false in running_builds_with -> left: None, right: Some({})
Control: install::tests::are_read_from_the_kernel_which_lists_this_process: seen_by answering argv: None for a readable process -> left: None, right: Some({})

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@inkless
inkless force-pushed the gz/bz-409-flake-install-running-builds-test-on-macos branch from 3f90336 to 11a6f3a Compare November 22, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0