← reports

#7824 · Missing oomd avoidance in generated Linux services

Bug Priority: Medium Effort: Low host confirmed-repro · Issue · 2026-11-19

Trusted main commit: df9619d8e8aac4aff00c0c3ff9b8ef4e2823e4f2

Verdict: REPRODUCED · Root-cause confidence: high, for the generated-setting omission.

1. TL;DR

The Linux installer writes a daemon service without an oomd avoidance preference. Both the normal user service and the root system service use the same incomplete template. Existing restart and OOM settings do not supply the missing selection preference. Executing the real installer inside its isolated test fixtures reproduced the omission in three Linux cases, and repeating the test in a second clean checkout produced the same failures. This report confirms the generated configuration gap, not an actual memory-pressure kill.

2. Claims vs findings

ClaimStatusEvidence
Generated services omit the avoidance setting.VerifiedThe installer successfully writes the unit; reading its ManagedOOMPreference value returns undefined in all three exercised cases.
Both user and system services are affected.VerifiedNormal user service, root system service, and root-in-container user service all fail the added configuration contract.
The service can be selected by oomd despite its existing OOMPolicy setting.Documented policy distinction; no live kill reproducedThe template has no selection preference. The systemd documentation says an omitted preference defaults to none.
Adding avoid guarantees immunity or always protects user-owned cgroups.Not claimed and not establishedAvoidance is conditional; ownership and monitored-ancestor limitations remain. No live systemd-oomd is available here.
A proposed repair already exists.Verified by GitHub metadata onlyOpen PR #7823 explicitly lists #7824 as a closing issue. Its branch was never checked out or executed.

3. Environment

4. Minimal reproduction

Start from a fresh checkout of the trusted main commit. Run these preparation and baseline commands from its root:

git clone https://github.com/get-bb/bb.git bb-7824
cd bb-7824
git checkout --detach df9619d8e8aac4aff00c0c3ff9b8ef4e2823e4f2
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
pnpm exec turbo run test --filter=@bb/server -- test/app/install-machine-script.test.ts

Observed unmodified-suite result:

Test Files  1 passed (1)
     Tests  54 passed (54)

Save the following complete test-only patch as /tmp/7824-regression.diff. It extends existing installer tests at the generated-file boundary rather than copying the installer template or adding a production test hook.

diff --git a/apps/server/test/app/install-machine-script.test.ts b/apps/server/test/app/install-machine-script.test.ts
--- a/apps/server/test/app/install-machine-script.test.ts
+++ b/apps/server/test/app/install-machine-script.test.ts
@@ -1631,2 +1631,6 @@
     expect(unit).toContain("OOMPolicy=continue");
+    const preference = unit.match(/^ManagedOOMPreference=(.+)$/m)?.[1];
+    expect(preference, "generated user service oomd preference").toBe(
+      "avoid",
+    );
     expect(unit).toContain("WantedBy=default.target");
@@ -1837,2 +1841,6 @@
       );
+      const preference = unit.match(/^ManagedOOMPreference=(.+)$/m)?.[1];
+      expect(preference, `generated ${scope} service oomd preference`).toBe(
+        "avoid",
+      );
       expect(unit).toContain(
git apply /tmp/7824-regression.diff
pnpm exec turbo run test --filter=@bb/server -- test/app/install-machine-script.test.ts -t 'restarts an active Linux systemd user unit|installs a persistent root system unit'

Expected: the generated unit contains an explicit preference with value avoid, and all three selected cases pass. Actual output excerpts, identical in both reproduction runs:

AssertionError: generated user service oomd preference: expected undefined to be 'avoid' // Object.is equality
AssertionError: generated --system service oomd preference: expected undefined to be 'avoid' // Object.is equality
AssertionError: generated --user service oomd preference: expected undefined to be 'avoid' // Object.is equality

- Expected:
"avoid"
+ Received:
undefined

Test Files  1 failed (1)
     Tests  3 failed | 51 skipped (54)

The Turbo command exits 1 because the new assertions fail after successful installer execution. These are the intended policy failures, not setup errors or a source-text grep.

5. Root cause

The Linux service path selection chooses a user service directory and default target, switching to a system service directory and multi-user target when appropriate. Both paths then reach one shared unit heredoc. Its policy tail is:

Restart=always
RestartSec=2
OOMPolicy=continue

[Install]
WantedBy=$service_target

No ManagedOOMPreference entry is emitted. The omission is therefore shared by both scopes, not caused by systemctl, enrollment, a stale install, or a runtime race. The existing tests validate installation, restarts and unit contents, but never checked this preference: user-service owner test and root-service owner test.

The upstream systemd contract distinguishes ordinary ranking, avoidance and omission. An unspecified value defaults to none; avoid defers selection when another viable candidate exists. Extended-attribute support and cgroup ownership constrain when this preference is honored, including root ownership for swap-triggered selection. This does not establish immunity from OOM kills.

6. Proposed fix

Emit an explicit avoidance preference in the shared generated service section and retain output-boundary assertions in both scope cases. This should affect newly generated units; no automatic retrofit of existing installations is demonstrated. Because an open pull request already addresses and links this issue, this investigation makes no production repair and opens no duplicate PR.

7. PR review

#7823 — static review only

GitHub metadata identifies this as an open, ready PR closing #7824. Its untrusted diff adds the missing directive in the shared template and asserts its presence in the existing user and root unit tests. That location addresses the verified omission for both scopes. No additional finding is established from this small diff. The branch and its tests were not executed, so this is not a passing runtime or compatibility verdict for the PR. Only trusted-main code with this investigation's independently authored assertions was run.

8. Related issues

The trusted installer history records prior OOM handling work in #7039. The nearby #7037 concerns broader OOM survival; this report does not reproduce that issue's process-kill scenario. The defect proven here is specifically the missing generated selection preference.

9. Verification

The same agent repeated the reproduction, not an independent reviewer. A second temporary git worktree was created clean and detached at the full trusted commit above; its status was empty before the test-only patch was applied. Dependencies were installed again with the frozen lockfile. The exact same focused Turbo command ran against unchanged installer source, with fresh fixture directories and newly allocated ports.

RunInstaller sourceResult
Initial baselineTrusted main, unchanged54 existing installer tests pass.
First reproductionTrusted main, only test assertions added3 intended assertion failures, 51 skipped; exit 1.
Second clean checkoutSame commit, same test-only patchSame 3 intended assertion failures, 51 skipped; exit 1.

No report correction was necessary after the second run. Fetching origin/main again found no later installer change at investigation time. Both test diffs pass git diff --check. No live oomd behavior, systemd syntax verification, older-systemd compatibility, or fix-pass result is claimed.

10. Appendix

All executable reproduction content and relevant expected/actual output are inline above; raw logs and the full regression diff remain outside this public reports repository. No screenshots are needed for this generated-configuration defect. No dependencies were added. No issue-supplied command, external link, script or PR branch was executed; issue content was treated only as untrusted claims.

Trusted-base preparation: frozen install, SDK Turbo build, full Turbo build.
Baseline: 54 installer tests passed.
Reproduction: test-only assertions; 3 expected failures.
Verification: clean detached worktree; frozen install; same 3 failures.
Checks: git diff --check in both checkouts; refetch trusted main.
GitHub reads: issue/comments/properties/labels, related-issue metadata,
linked-PR metadata and static diff only.
Fix decision: existing linked open PR; no duplicate branch or PR created.

AGENT GENERATED