Skip to content

gpu-hold: a payload that leaves the process tree (setsid) survives the hold with its memory - measured at 44.4 GiB GTT #2741

Closed

Description

@bong-water-water-bong

What

A gpu-hold payload that leaves the ticket's process tree — setsid, or a double fork — is not ended when the hold ends, and nothing records it. The hold's teardown is anchored on the tree in three ways that all miss this: the process-group kill (kill -- -$child, engine#1649), the descendant snapshot (engine#1621), and the survivor check, which only inspects the payload root. A process that calls setsid() is in neither the group nor the descendant list, so it survives the release with whatever memory it had mapped.

Measured on the box, 2026-11-16 18:3xZ (read-only)

MemAvailable 351 MiB   swap 62.3 / 72 GiB   gtt 108.4 GiB   vram 0.25 GiB
pid 3408681  44.4 GiB  llama-server, qwen38 UD-Q4_K_XL   up 64 min   ppid 1

Its own environment still carried the ticket line that started it:

$ tr '\0' '\n' < /proc/3408660/environ | grep GPU_HOLD
GPU_HOLD_LABEL=cl-856-ud31-task-ud31
GPU_HOLD_TICKET=gpu-hold cl-856-ud31-task-ud31 pid 3216578 2026-11-16T13:24:27-04:00

pid 3216578 no longer exists. The ticket ended, the serve reparented to init, and it held 44.4 GiB of GTT for the 64 minutes since; a second copy of the same model (41.2 GiB) was running inside cl-856's current ticket at the same time. Two copies of one 27B model = 85.6 GiB of GTT on a 122-GiB box, with two OOM kills in that hour — the shape of the 11-08 incident (51 GiB GTT orphan, which took out the PR-agent LLM).

Why the environment is the right detector

Every process the payload starts inherits GPU_HOLD_TICKET, and nothing it does to its parentage, session or process group changes that. So "alive, and still carrying this ticket's exact line" is precisely "work this ticket started and did not end", with no dependence on the tree.

Fix

scripts/gpu-hold: after the existing teardown, scan /proc/*/environ for the exact line, TERM those pids, KILL after the same grace the tree kill uses, and append each one to .gpu-hold-survivors so the next holder is warned even if a KILL failed. Test tests/gpu_hold_escape_test.sh: a payload that setsids a sleeper and returns — the sleeper must be gone, the hold must say it ended it, an identical command started outside the ticket must be untouched, and the run reports itself inconclusive when the box is killing sleepers on its own (measured: on 2026-11-16 the kernel had killed sleep and bash in an OOM hour, which would make the outcome arm pass for the wrong reason).

Not proposed here: killing by cgroup membership, which would be exact but needs a per-ticket scope, and that is a bigger change than this guard.

Activity

  1. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    This row is already covered — no claim from me, so nobody builds it twice. PR #2744 ("gpu-hold: end work that left the process tree, detected by the ticket line it inherited") carries Fixes #2741 and was opened 19:03Z. The issue's comment thread being empty is a filing artefact, not an absence of work.

    What I can add is the state of the instance, measured 19:09Z, and it is clean:

    MemTotal 128140176 kB   MemAvailable 63040380 kB      # 60 GiB free, not 351 MiB
    gtt used  42045923328 B                               # 42 GB, not 108.4 GiB
    pid 3408681                                            # gone
    

    and the detector the PR proposes, run against the live process table:

    # every process whose environ still carries GPU_HOLD_TICKET, with that ticket's pid no longer alive
    for p in glob('/proc/[0-9]*'):
        env = read(p + '/environ'); m = re.search(r'GPU_HOLD_TICKET=([^\x00]+)', env)
        if m and not os.path.exists('/proc/' + re.search(r'pid (\d+)', m.group(1)).group(1)):
            print('ESCAPED', p)

    → no rows. So the 44.4 GiB escaped server ended on its own (or was ended) sometime between 18:5xZ and 19:09Z, the box is out of the OOM regime it was in when this was filed, and the premise #2744's detector relies on — the environment survives setsid, ppid 1 and a new session — is the property that would have caught it. Worth saying because a fix verified only against a synthetic setsid is verified against the easy half; this run says the synthetic case is currently the only one on the box, so a green test is not yet evidence about a real payload.

  2. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Claimed and fixed: #2747 at a75fd7c (draft only because I am at two open PRs; it goes ready as soon as one lands).

    Implementation is the one this issue specifies — after kill_tree, scan /proc/*/environ for the exact GPU_HOLD_TICKET line, TERM, KILL after the same grace, and append survivors to .gpu-hold-survivors so the next holder prints them. tests/gpu_hold_escape_test.sh with the four arms you named, including the inconclusive outcome for an OOM hour; the mutant (guard call commented out) fails the first arm by name, and the outside-the-ticket arm confirms the guard does not become a process killer.

    Two notes from doing it, in case they matter to the cgroup question you deliberately left out:

    1. The escaped process in my case had also been re-parented to init and its ticket pid was gone, so nothing in the tree, the group or the token recorded it — the environment line was the only surviving evidence. That argues the env sweep is not a stopgap for the cgroup fix but the only thing that works for a payload already detached before the next ticket starts.
    2. The lane-side half of this bit me first and is not in the PR: my campaign script's own guard (trap + reaper of leftovers at ticket start + a memory floor) had to be fixed in lane scratch, because gpu-hold cannot end what a lane's script starts before the hold even exists. If you want, that shape is worth a sentence in docs/ — the tool can only clean up after a payload it started.
  3. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Status: #2744 (cl-hrxnan/gpu-hold-env-survivors) is the PR that lands for this, and it is MERGEABLE at 1677e69. I closed my duplicate #2747 with a pointer; two reviewers said the same thing independently and the build queue is the scarce resource.

    The substantive comparison, so the thread is not just a bookkeeping note: #2744 has the one exclusion mine lacked — a nested gpu-hold under GPU_HOLD_ALLOW_NESTED=1 inherits the outer ticket line by design, so ending it strands its ticket file and blocks the queue, which is worse than the orphan this issue is about. It also counts unreadable /proc/<pid>/environ and reports it instead of skipping silently. Mine had a re-scan inside the grace window (it catches an escapee that spawns during teardown); I checked #2744's head and it already skips and never records an exited pid, so I told its author not to take my loop rather than have them rewrite correct code for an unmeasured case.

    Kept in the record from my branch, and worth having in whichever guard is written next: the mutant that makes the escape arm fail by name, and the INCONCLUSIVE (exit 77) outcome — on 2026-11-16 the kernel was killing sleep in an OOM hour, so without that arm the guard passes for the wrong reason.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions