[BUG] Realm retirement releases ownership before the terminal event is consumed #6

Open
opened 2026-09-24 20:00:11 +02:00 by erikinkinen · 0 comments
Owner

Summary

Successful running-realm retirement can release Launchd's original child owner before its queued terminal event is consumed. Procd queues a visible RealmMediator event before acknowledging final retirement. Launchd blocks ordinary WAIT while retiring, then releases the realm record immediately after replying to public ABORT. A later valid event can therefore match neither a retained realm nor an ordinary job and stop the dispatcher.

This is a source-confirmed lifetime gap found while reviewing native acceptance criteria. It is separate from both the repaired WAIT role decoder and the current earlier START failure. No actual guest failure caused by this post-retirement path is claimed.

Reproduction

At Launchd eb2a1eedabe66e01ab0eb8c630d2f06ecb67b68d and Procd d04311abff67e7355bd92bb2e48fb6161e0ec674:

  1. Start a private realm and retain its exact child process/generation.
  2. Request public ABORT. Let Procd terminate that running child, retire its custody, queue the visible RealmMediator terminal event and complete the private RETIRE operation.
  3. Complete the public Retired reply so Launchd releases its realm record.
  4. Deliver the already queued terminal event through Launchd's authenticated Procd WAIT route.

This ordering follows the retained-owner gate: ordinary process-event intake is paused while the native retirement owner remains pending. A never-started staged abort is a different path and need not generate this running terminal event.

Expected and actual behavior

The original child generation must remain attributable until both final native retirement and its visible terminal-event obligation have a coherent acknowledgment. Later service requests must continue after either explicit retirement or unsolicited child termination. The correction must not discard arbitrary unmatched events or use untrusted scalar identifiers as authority.

Procd's running realm retirement unconditionally queues an event before it becomes eligible for a Retired response. Unlike ordinary Launchd STOP, it does not remove that exact queued event as part of acknowledgment. Launchd then clears its realm record. When ordinary WAIT resumes, the repaired decoder accepts the RealmMediator role, but the dispatcher cannot find the former realm owner and falls through to ordinary-job lookup, which errors for the mediator. This can produce a ProcessEvent fail-stop after an otherwise successful public retirement.

Environment and identity

  • Launchd eb2a1eedabe66e01ab0eb8c630d2f06ecb67b68d; Procd d04311abff67e7355bd92bb2e48fb6161e0ec674; selected Integration fa857c0964774def6777142afeb7a3c16440abee; Kernel 5e285aa91a1423523b2a094d4ce0449ada39b16c; Posixd 809647d60544c4c6121868c99133f30d054965c9.
  • Source-level lifecycle ordering in the native runtime. The actual selected release x86-64 QEMU/OVMF scenario uses development runtime configuration, one virtual CPU and Rust 1.97.1.
  • Event identity arrives only through Launchd's existing authenticated Procd route; original child generation, owned retirement and exact cleanup evidence must remain enforced.
  • Last known working revision is unestablished. The current native run fails at START before running retirement, so it neither reproduces nor validates this path.

Evidence and prior checks

  1. Procd retained RETIRE waits for terminal state and empty custody. RealmMediator terminal handling calls terminal commit, which queues the visible event. By comparison, ordinary STOP explicitly takes its exact event.
  2. Launchd dispatch gating blocks ordinary WAIT while native retirement remains pending. Successful ABORT reply then releases the original realm record.
  3. Record release clears the child identity. Child lookup consults only retained owners. Process-event dispatch falls through to ordinary-job lookup when that identity is gone.

The unchanged two-mediator scenario checks startup, independent acknowledged retirement and stale public reads, but has no explicit terminal-event-consumption acknowledgment. A positive ABORT reply alone cannot prove the repaired WAIT decoder was exercised; a completed powerbox expiration can also consume its work-class turn before WAIT runs. Host regression and source-bound native event evidence remain required. No runtime execution, retry or timeout change was performed for this review.

Tracking

Launchd lifecycle audit, Launchd PR 2, Posixd realm lifecycle, Integration validation, and Phase 6 completion. The WAIT decoder defect covers admissible event roles; this report covers lifetime of the owner after decoding. The earlier START failure currently prevents native execution from reaching this boundary.

  • Reproduce final retirement followed by delivery of the exact queued RealmMediator event, including record-slot reuse and independent second-realm survival.
  • Preserve an exact-generation event handoff through final retirement; retain strict rejection of unowned or wrong-generation events.
  • Keep unsolicited running-child termination and never-started staged abort semantics correct.
  • Complete formatting, strict Clippy, relevant unit tests and warning-denied host/native build and documentation checks.
  • Demonstrate actual terminal-event handling and continued service in a source-bound native scenario before closing native acceptance.

Producer ownership refinement: the owning correction is tracked in Procd 7 and Procd PR 2. After proving the original child's terminal disposition and capability cleanup, explicit RETIRE must consume only its exact queued visible event before completing its retained successful response, analogous to ordinary STOP. Unrelated generations and spontaneous terminal events remain available to WAIT. Launchd must not wait unconditionally for a second event because a rejected or lost start can still concern a never-started staged child. No unmatched-event swallowing or inferred replacement owner is required. This report remains open as the downstream symptom and acceptance record.

## Summary Successful running-realm retirement can release Launchd's original child owner before its queued terminal event is consumed. Procd queues a visible RealmMediator event before acknowledging final retirement. Launchd blocks ordinary WAIT while retiring, then releases the realm record immediately after replying to public ABORT. A later valid event can therefore match neither a retained realm nor an ordinary job and stop the dispatcher. This is a source-confirmed lifetime gap found while reviewing native acceptance criteria. It is separate from both the repaired WAIT role decoder and the current earlier START failure. No actual guest failure caused by this post-retirement path is claimed. ## Reproduction At Launchd `eb2a1eedabe66e01ab0eb8c630d2f06ecb67b68d` and Procd `d04311abff67e7355bd92bb2e48fb6161e0ec674`: 1. Start a private realm and retain its exact child process/generation. 2. Request public ABORT. Let Procd terminate that running child, retire its custody, queue the visible RealmMediator terminal event and complete the private RETIRE operation. 3. Complete the public Retired reply so Launchd releases its realm record. 4. Deliver the already queued terminal event through Launchd's authenticated Procd WAIT route. This ordering follows the retained-owner gate: ordinary process-event intake is paused while the native retirement owner remains pending. A never-started staged abort is a different path and need not generate this running terminal event. ## Expected and actual behavior The original child generation must remain attributable until both final native retirement and its visible terminal-event obligation have a coherent acknowledgment. Later service requests must continue after either explicit retirement or unsolicited child termination. The correction must not discard arbitrary unmatched events or use untrusted scalar identifiers as authority. Procd's running realm retirement unconditionally queues an event before it becomes eligible for a Retired response. Unlike ordinary Launchd STOP, it does not remove that exact queued event as part of acknowledgment. Launchd then clears its realm record. When ordinary WAIT resumes, the repaired decoder accepts the RealmMediator role, but the dispatcher cannot find the former realm owner and falls through to ordinary-job lookup, which errors for the mediator. This can produce a ProcessEvent fail-stop after an otherwise successful public retirement. ## Environment and identity - Launchd `eb2a1eedabe66e01ab0eb8c630d2f06ecb67b68d`; Procd `d04311abff67e7355bd92bb2e48fb6161e0ec674`; selected Integration `fa857c0964774def6777142afeb7a3c16440abee`; Kernel `5e285aa91a1423523b2a094d4ce0449ada39b16c`; Posixd `809647d60544c4c6121868c99133f30d054965c9`. - Source-level lifecycle ordering in the native runtime. The actual selected release x86-64 QEMU/OVMF scenario uses development runtime configuration, one virtual CPU and Rust 1.97.1. - Event identity arrives only through Launchd's existing authenticated Procd route; original child generation, owned retirement and exact cleanup evidence must remain enforced. - Last known working revision is unestablished. The current native run fails at START before running retirement, so it neither reproduces nor validates this path. ## Evidence and prior checks 1. [Procd retained RETIRE](https://git.erikinkinen.fi/erix/procd/src/commit/d04311abff67e7355bd92bb2e48fb6161e0ec674/src/runtime_realm_producer.rs#L329) waits for terminal state and empty custody. [RealmMediator terminal handling](https://git.erikinkinen.fi/erix/procd/src/commit/d04311abff67e7355bd92bb2e48fb6161e0ec674/src/processes_lifecycle.rs#L413) calls [terminal commit](https://git.erikinkinen.fi/erix/procd/src/commit/d04311abff67e7355bd92bb2e48fb6161e0ec674/src/process_terminal_commit.rs#L98), which queues the visible event. By comparison, [ordinary STOP](https://git.erikinkinen.fi/erix/procd/src/commit/d04311abff67e7355bd92bb2e48fb6161e0ec674/src/runtime_policy.rs#L277) explicitly takes its exact event. 2. [Launchd dispatch gating](https://git.erikinkinen.fi/erix/launchd/src/commit/eb2a1eedabe66e01ab0eb8c630d2f06ecb67b68d/src/runtime/dispatcher.rs#L69) blocks ordinary WAIT while native retirement remains pending. [Successful ABORT reply](https://git.erikinkinen.fi/erix/launchd/src/commit/eb2a1eedabe66e01ab0eb8c630d2f06ecb67b68d/src/runtime/realm_reply.rs#L209) then releases the original realm record. 3. [Record release](https://git.erikinkinen.fi/erix/launchd/src/commit/eb2a1eedabe66e01ab0eb8c630d2f06ecb67b68d/src/realm_admission_retirement.rs#L141) clears the child identity. [Child lookup](https://git.erikinkinen.fi/erix/launchd/src/commit/eb2a1eedabe66e01ab0eb8c630d2f06ecb67b68d/src/realm_admission_scheduler.rs#L19) consults only retained owners. [Process-event dispatch](https://git.erikinkinen.fi/erix/launchd/src/commit/eb2a1eedabe66e01ab0eb8c630d2f06ecb67b68d/src/runtime/dispatcher_process_event.rs#L25) falls through to ordinary-job lookup when that identity is gone. The unchanged two-mediator scenario checks startup, independent acknowledged retirement and stale public reads, but has no explicit terminal-event-consumption acknowledgment. A positive ABORT reply alone cannot prove the repaired WAIT decoder was exercised; a completed powerbox expiration can also consume its work-class turn before WAIT runs. Host regression and source-bound native event evidence remain required. No runtime execution, retry or timeout change was performed for this review. ## Tracking [Launchd lifecycle audit](https://git.erikinkinen.fi/erix/launchd/issues/1), [Launchd PR 2](https://git.erikinkinen.fi/erix/launchd/pulls/2), [Posixd realm lifecycle](https://git.erikinkinen.fi/erix/posixd/issues/1), [Integration validation](https://git.erikinkinen.fi/erix/integration/issues/3), and [Phase 6 completion](https://git.erikinkinen.fi/erix/integration/issues/65). [The WAIT decoder defect](https://git.erikinkinen.fi/erix/launchd/issues/3) covers admissible event roles; this report covers lifetime of the owner after decoding. [The earlier START failure](https://git.erikinkinen.fi/erix/launchd/issues/5) currently prevents native execution from reaching this boundary. - [ ] Reproduce final retirement followed by delivery of the exact queued RealmMediator event, including record-slot reuse and independent second-realm survival. - [ ] Preserve an exact-generation event handoff through final retirement; retain strict rejection of unowned or wrong-generation events. - [ ] Keep unsolicited running-child termination and never-started staged abort semantics correct. - [ ] Complete formatting, strict Clippy, relevant unit tests and warning-denied host/native build and documentation checks. - [ ] Demonstrate actual terminal-event handling and continued service in a source-bound native scenario before closing native acceptance. Producer ownership refinement: the owning correction is tracked in [Procd 7](https://git.erikinkinen.fi/erix/procd/issues/7) and [Procd PR 2](https://git.erikinkinen.fi/erix/procd/pulls/2). After proving the original child's terminal disposition and capability cleanup, explicit RETIRE must consume only its exact queued visible event before completing its retained successful response, analogous to ordinary STOP. Unrelated generations and spontaneous terminal events remain available to WAIT. Launchd must not wait unconditionally for a second event because a rejected or lost start can still concern a never-started staged child. No unmatched-event swallowing or inferred replacement owner is required. This report remains open as the downstream symptom and acceptance record.
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:34:31 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
erix/launchd#6
No description provided.