Skip to content

killUser: Don't let the child kill itself on Apple - #152

Closed
shlevy wants to merge 1 commit into
NixOS:masterfrom
shlevy:handle-darwin-kill
Closed

shlevy wants to merge 1 commit into
NixOS:masterfrom
shlevy:handle-darwin-kill

Conversation

@shlevy

@shlevy shlevy commented Jul 30, 2013

Copy link
Copy Markdown
Member

The kill(2) in Apple's libc follows POSIX semantics, which means that
kill(-1, SIGKILL) will kill the calling process too. Since nix has no
way to distinguish between the process successfully killing everything
and the process being killed by a rogue builder in that case, it can't
safely conclude that killUser was successful.

Luckily, the actual kill syscall takes a parameter that determines
whether POSIX semantics are followed, so we can call that syscall
directly and avoid the issue on Apple.

Signed-off-by: Shea Levy [email protected]

The kill(2) in Apple's libc follows POSIX semantics, which means that
kill(-1, SIGKILL) will kill the calling process too. Since nix has no
way to distinguish between the process successfully killing everything
and the process being killed by a rogue builder in that case, it can't
safely conclude that killUser was successful.

Luckily, the actual kill syscall takes a parameter that determines
whether POSIX semantics are followed, so we can call that syscall
directly and avoid the issue on Apple.

Signed-off-by: Shea Levy <[email protected]>
@edolstra

Copy link
Copy Markdown
Member

Applied, thanks!

@edolstra edolstra closed this Jul 30, 2013
zolodev pushed a commit to zolodev/nix that referenced this pull request Jan 1, 2024
zolodev pushed a commit to zolodev/nix that referenced this pull request Jan 1, 2024
Add tutorial for integration testing using virtual machines
angerman added a commit to angerman/nix that referenced this pull request Aug 5, 2026
… executable form

Build plan for Change 4 (the second surviving lever; NixOS#137 RCA'd it: narrows the
warm gap 2.49x ff/1.83x M5 to ~1.5-2.2x, doesn't beat TW alone -> sequenced AFTER
HAMT).  Foundations J0-J3 proven standalone (research/jit_*.cc).

De-risking insight (same shape as the HAMT GC plan): the J3 crux — JIT'd native
code must spill live v3 pointers at allocation safepoints so the moving scavenger
finds/updates them — maps onto the PROVEN GcRoot/walkAllV3Roots mechanism
(precise_root.cc:196 already scans Values registered via GcRoot from C++ frames).
A JIT'd frame maintains a shadow live-Value list enumerated by walkAllV3Roots;
no new GC-root theory, mirror GcRoot.

Steps: NixOS#152 real-scavenger safepoint spill (shadow frame + register with
walkAllV3Roots); NixOS#153 value-stack ABI trampoline + hot-callCount compile trigger +
deopt/bail (small opcode subset first, grow behind byte-id); NixOS#154 validate
(byte-id + --brute under 1MB-nursery moving-GC stress with ALLOCATING JIT'd bodies
= exercises the spill crux) + darwin-4 measure + ship behind NIX_V3_JIT.  Must
cover allocating bodies (pure-arith = gaming, forbidden).

Both real levers (HAMT NixOS#1, JIT NixOS#2) now blueprinted to executable form; both
multi-week, gated.

lode/C4_JIT_BUILD_PLAN_2026-06-23.md.

Copyright (c) 2026 Moritz Angermann <[email protected]>, Input Output
Group. SPDX-License-Identifier: Apache-2.0
angerman added a commit to angerman/nix that referenced this pull request Aug 5, 2026
…S0-S4)

Rule 0 — records the fully-scoped program for the safepoint foundation (the shared
prerequisite for compacting mid-eval GC + native codegen, per the yield estimate
7ddad6b). Decomposed into 14 ordered, dependency-wired, measure-gated tasks
(NixOS#163-173 new + NixOS#152-154 reframed as S3):

  S0 de-risk/go-no-go: S0.1 warm-peak reclaimable ceiling (GO if dead>=30% & M5<=2.0x),
     S0.2 re-entrant root census, S0.3 architecture decision (Bartlett vs precise handles)
  S1 foundation: S1.1 Handle/HandleScope movable-root API, S1.2 migrate re-entrant
     primop sites (auditor-gated), S1.3 safepoint polls, S1.4 validate non-moving
     mid-eval (auditor zero-missed = THE correctness gate)
  S2 RSS exploit: S2.1 mid-eval compactor, S2.2 whole-block-free+munmap+trigger,
     S2.3 measure RSS (ship >= 70% of S0.1 ceiling)
  S3 CPU exploit (was C4 JIT): S3.1 stack maps for JIT'd code (J3, now unblocked by S1),
     S3.2 codegen backend+trampoline+deopt, S3.3 validate under moving GC (ship >=15% wall)
  S4 integration: S4.1 combined head-to-head + RSS/CPU Pareto tune

Critical path S0->S1->{S2 || S3}->S4. Bartlett path lets S2 (RSS) ship without the full
S1.2 handle migration; codegen (S3) needs S1's stack-map protocol. Every code phase
gated by full --brute + byte-id; perf darwin-4-only; each phase has a pre-committed
threshold. S0 is a real go/no-go. Honest outcome: COMPETITIVE (~1.3-2x both axes) +
movable-GC/codegen substrate for incremental/parallel eval — NOT guaranteed <1x (the
heavier live rep + bytecode metadata is a residual needing the container/churn work on
top). Full scope: lode/SAFEPOINT_FOUNDATION_PROGRAM_2026-06-24.md

Copyright (c) 2026 Moritz Angermann <[email protected]>, Input Output
Group. SPDX-License-Identifier: Apache-2.0
angerman added a commit to angerman/nix that referenced this pull request Aug 5, 2026
…les(codegen)

Rule 0 — S0.3 (NixOS#165) commits the architecture from the S0.1+S0.2 data (git-noted
d12d11e/746fbc219). Phase S0 (de-risk) COMPLETE → GO.

DECISION — two collectors share one safepoint, split by axis:
- RSS exploit (S2) = BARTLETT mostly-copying. At peak only 3.6% (M5) / 12.5% (firefox)
  of live cells are conservative-C-stack-only, so pin-those + compact-the-rest captures
  ~87-96% of the reclaim with NO handle migration. The mid-eval mark-sweep ALREADY runs
  at exitDepth>0 (value-stack consistent + conservative C-stack scan + remembered set) —
  it's non-moving only because moving was gated off. S2.1's real work is the MOVER, not
  new safepoint plumbing.
- CPU exploit (S3) = precise handles + JIT stack maps (codegen can't use conservative
  pinning of hot frames). ~7 hot primops to wrap (~25 LoC) + JIT map emission.

RE-SEQUENCED: RSS path (S1.3 verify-safepoint -> S1.4 roots-complete -> S2.1 mover ->
S2.2 -> S2.3) DECOUPLES from codegen path (S1.1 handles -> S1.2 migrate -> S3.1 maps ->
S3.2 -> S3.3); after S0.3 they run in PARALLEL. (NixOS#152 now also blockedBy NixOS#167.)

Open refinements for S2.1 (don't block S0.3): pin at 128B LINE granularity; both-
reachable cells must pin (true pinned >= measured conservativeOnly); the mover must
RELOCATE via the remembered set (S0.2: dirty-list marks 61-181K cells precise misses).

Realized estimate: Bartlett ~90% capture -> firefox ~1.15-1.25x / M5 ~1.4-1.5x RSS
(better than the original envelope). Decision doc:
lode/SAFEPOINT_FOUNDATION_S0.3_DECISION_2026-06-24.md

Copyright (c) 2026 Moritz Angermann <[email protected]>, Input Output
Group. SPDX-License-Identifier: Apache-2.0
angerman added a commit to angerman/nix that referenced this pull request Aug 5, 2026
…safepoints) — narrows, doesn't beat TW

Scoped the warm-eval-targeted optimizing JIT with J3 GC-safepoints as the centerpiece
(forked analysis with full campaign context; reads research/jit_*.cc + jit.hh + the
safepoint/root machinery). Key findings:

J3 IS DE-RISKED — no pc-indexed stack maps. The contract-proven design (research/
jit_safepoint_test.cc): spill every live v3-pointer Value to vm.valueStack before any
allocation safepoint, keep none in a register across it, reload after. vm.valueStack is
ALREADY enumerated by walkAllV3Roots (the scavenger's root source), so the moving GC
finds+forwards them with zero new root machinery. J3 = "emit the interpreter's existing
per-op GC-root discipline in native code," not a stack-map subsystem. J0-J3 all proven
standalone; what's missing is integration (NixOS#152-154).

WARM-FRAMING: surface-simplifies (compile only hot RUN bodies, bail-to-interpreter for
cold/unsupported/throw) but can't skip J3 (hot nixpkgs bodies allocate; non-allocating JIT
= ~0 coverage = gaming). Minimal viable = J2 emitter + value-stack-spill safepoints +
value-stack-ABI trampoline + callCount trigger + bail. ~4-6 weeks (copy-patch, no reg-alloc).

CEILING (honest): copy-patch → ~1.5-2.2× TW (dispatch removal) minus a safepoint spill/reload
tax; optimizing reg-alloc adds only the reg-VM-measured cheap ~5-10% → ~1.3-1.8×, STILL >1×.
ALLOC ~20% + countDistinct ~16% + CALL_PRIMOP/ATTRS_SELECT/STR_CONCAT real work remain. An
optimizing JIT does NOT beat TW on its own — beating TW needs it to ALSO attack the residue
(inline bump-alloc + escape-analysis stack-alloc of non-escaping thunks + inline caches +
inline primops = multi-month) PLUS the orthogonal allocate-less + leaner-cell changes. The
JIT is 1 of ~4 changes and the only one that merely narrows.

Doc: lode/WARM_EVAL_JIT_SCOPING_2026-06-29.md
Copyright (c) 2026 Moritz Angermann <[email protected]>, Input Output Group.
SPDX-License-Identifier: Apache-2.0
roberth added a commit to roberth/nix that referenced this pull request Aug 9, 2026
…electorApply cell

Diagnosis (task NixOS#152 class, applied under NixOS#177): warm's callback
apply Q found Terminal at cur=∅ immediately (0 facts dispatched),
returning cold's answer regardless of warm's callback content.
Cold's Terminal for the callback SelectorApply was inserted at
cell.ownFactSet=∅ because QCA observations were attributed to
`callbackCell` (OuterApply::run's localCell), which is a
different cell from activeQueryStack.back()'s SelectorApply cell.
Broadcast env-fact fold reached both cells, but QCA — the
sibling-discriminating fact — only landed on callbackCell. The
SelectorApply cell's ownFactSet stayed at ∅, its Terminal keyed
at ∅, and warm walkers hit trivially.

Fix: in emitCallbackApplyForApplyResult, pass `activeQueryStack.
back()->cell.lock()` as attributionCell — the enclosing
SelectorApply's cell. callbackCell stays as the lookup handle for
the runningObsSet content (via tryEmitFromCell). QCA fact now
folds into SelectorApply cell.ownFactSet → distinct Terminal per
sibling based on obsSet content → warm sibling B walks to a cur
that has no cold Terminal → cleanly misses.

Suite: 304/24 (from 303/25). Net +1:
- Newly passing: cb-obsset-mismatch-clean-miss,
  cb-stats-pre-flush-collision, cb-two-sibling-distinct-callbacks.
- Newly failing: cb-local-descendants,
  cb-xor-evolution-repeated-cb-apply.

The regressions look adjacent to the callback path — the
attribution fix may be over-attributing in some scenarios. Next
diagnosis on cb-local-descendants or cb-xor-evolution.

Assisted-by: Claude Code (Claude Opus 4.6-4.7)
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.

2 participants