Skip to content

perf(host): Windows kernel Token leak, one per child-creating process, amplified by hook and Bash fan-out (melo-lap-001, melo-desk-001) #4372

Description

@kyle-sexton

Summary

Both Windows workstations leak kernel Token objects. Each process that creates a child, while a foreground-lock condition holds, leaves one dead primary token behind until reboot.

Numbers

host build uptime Token objects token-family pool spawn floor
melo-desk-001 (#3715) 26200.x 2 d 3,811,482 paged pool 9.9 GB total cmd 1.3 to 1.6 s (14 ms after reboot)
melo-lap-001 (2026-09-23) 26200.9457 69 h 512,049 (about 2.1/s since boot) Toke 1,062 MB + Se* about 360 MB = about 1.4 GB bash 10 ms, cmd 10 ms: no penalty yet

The melo-lap-001 pool tags come from an unelevated SystemPoolTagInformation read:

Measured leak per spawn

melo-lap-001, N=300 per row, quiet host. Idle-window SD was 18 per 60 s.

command child-creating processes leaked tokens / spawn (±band)
usr/bin/bash -c true 0 0.00 (±0.13)
usr/bin/bash -c /usr/bin/true 1 1.04 (±0.13)
usr/bin/bash -c 'x=$(:); (:)' 1 1.04 (±0.14)
usr/bin/bash -c 2 externals 2 2.15 (±0.15)
usr/bin/bash -c 5 externals 6 5.95 (±0.18)
cmd /c "cmd /c exit 0" 1 0.96 (±0.14)
Git cmd/git.exe, Git bin/bash.exe (launchers) 1 0.99, 1.01
gh --version 1 0.98

Leaked tokens equal the number of processes that created a child. Which binary it is does not matter.

Open question: when is it armed?

  • Prediction: live ForegroundLockTimeout is 2147483647, and bentoner's model says the leak is always armed at that value.
  • Observed here: known creators leaked 1.0 each after 10 to 32 min with no user input, and about 0 to 0.24 when input was recent.
  • Live sample: a 10 min window with about 4 creators per second showed a net change of 0.

This rests on three conditions and is confounded with time. If it holds, the leak runs hardest during unattended loops and overnight. The operator A/B (typing, hands-off, screen locked) is listed under Next actions.

Config-side levers (per unit, measured)

  • External commands: each one in a bash hook, statusline, or Bash-tool script adds 1 token. Builtins, subshells and $(...) add nothing beyond bash's own 1.
  • Launcher shims: Git bin/bash.exe, Git cmd/git.exe, and the uv python.exe trampoline each add 1. Use usr/bin/bash.exe and mingw64/bin/git.exe directly.
  • Exec-form hooks: a hook running a binary that spawns nothing adds 0.
  • ollama tray app: it respawns ollama.exe about 0.5 times per second, about 13% of observed creators.

Next actions (operator)

  • Before the next reboot of either host, capture pool tags in an elevated shell: poolmon /iToke and poolmon /iWC*, with /g for the driver column. perf(host): melo-desk-001 process creation costs 1.4 to 4 s system-wide; 3.81M leaked kernel Token objects (~10 GB paged pool) since boot #3715 missed this capture.
  • Run the typing / idle / locked A/B (bash_5ext arm bracketed by null arms) to settle when the leak is armed.
  • Run a sampler for 2 h or longer that logs Token count, creators, and input-idle age.
  • Decide on ForegroundLockTimeout=0 (bentoner's workaround). Defer until the A/B is done; it lets any application steal focus.
  • Reduce fork counts per hook and statusline. This is tracked with the hook fan-out work in this repository.

Upstream


🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-humanHuman-in-the-loop required; autonomous sessions must not resolve items carrying this.priority: mediumReal value, no hard deadline; normal backlog flow.

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions