Skip to content

containerd-shim-runc-v2 remains alive with zero children after container PID 1 death, blocking all daemon API calls #13849

Open

Description

@ThePlenkov

Description

containerd-shim-runc-v2 enters a degenerate state when the container's PID 1 process dies (crash/OOM): the shim remains alive in futex_wait_queue with zero child processes and never emits a task-exit event. The Docker daemon considers the container "running", causing all API calls to that container (stop, kill, rm -f, inspect, logs, top, stats) to block indefinitely. There is no timeout and no automatic recovery — only kill -9 on the shim PID resolves it.

This is distinct from #13326 (CmdDel blocking on CNI socket) and moby/moby#40145 (reaper.Wait mutex) — here the shim simply never detects that its child process set is empty.

Steps to reproduce the issue

  1. Run a container with an application that can crash or be OOM-killed (e.g. LiteLLM with Prisma, which is known to create zombie processes — Zombie process: Prisma, connection to database interrupted BerriAI/litellm#14739)
  2. Run multiple instances sharing backing services (Postgres/Redis) to increase resource pressure
  3. Wait for the container process to crash under memory pressure (high swap usage observed: 10Gi/12Gi)
  4. The shim remains alive with zero children; all Docker API calls to that container hang forever

Exact reproduction timing is non-deterministic (depends on when the application process crashes), but the degenerate shim state is deterministic once the crash occurs.

Describe the results you received and expected

Received:

  • Container PID 1 exited, but containerd-shim-runc-v2 remained alive in S (sleeping) on futex_do_wait
  • Shim had zero child processes (verified via /proc/$pid/task/*/children)
  • docker ps showed containers as running (unhealthy)
  • docker stats --no-stream showed -- / -- (daemon couldn't read cgroup metrics)
  • Every API call to those containers blocked indefinitely: stop, kill, rm -f, inspect, logs, top
  • Non-affected containers on the same daemon responded normally

Expected:

  • Shim should detect that PID 1 has exited and emit a task-exit/task-delete event
  • Daemon should mark the container as exited/dead
  • At minimum, shim should have a timeout on futex_wait when children == 0

Evidence

Shim state from inside Docker Desktop VM

# Accessed via: docker run --rm --pid=host --privileged alpine

# 4 shims alive with zero children
for pid in 1842 1929 2016 2103; do
  children=$(cat /proc/$pid/task/*/children 2>/dev/null)
  state=$(cat /proc/$pid/status | grep State)
  wchan=$(cat /proc/$pid/wchan 2>/dev/null)
  echo "PID $pid: children=[${children:-NONE}] $state wchan=$wchan"
done

# Output:
# PID 1842: children=[NONE] State: S (sleeping) wchan=futex_wait_queue
# PID 1929: children=[NONE] State: S (sleeping) wchan=futex_wait_queue
# PID 2016: children=[NONE] State: S (sleeping) wchan=futex_wait_queue
# PID 2103: children=[NONE] State: S (sleeping) wchan=futex_wait_queue

Timeline from Docker Desktop backend logs

Time Event
14:54:46 All 4 containers healthy (port-forwarding active)
14:57:06 compose/v5.3.1 stops 2 non-litellm containers — completes in 4 sec
14:57:11 compose/v5.3.1 sends POST /stop to affected container — no response ever
15:08:07 POST /kill?signal=KILL — no response
15:09:10 compose timeout after 5 minutes, exit status 1

The containers were already in zombie state before any stop/kill was attempted — the very first stop hung immediately.

Resolution

# Only kill -9 on the shim PIDs resolved it
docker run --rm --pid=host --privileged alpine sh -c 'kill -9 1842 1929 2016 2103'
# Daemon then reconciled: containers marked Exited (255)

What version of containerd are you using?

containerd v2.2.5 (e53c7c1516c3b2bff98eb76f1f4117477e6f4e66)

Any other relevant information

  • Docker Desktop: 4.83.0 (234302)
  • Docker Engine: 29.6.2
  • runc: 1.3.6
  • Kernel: 6.18.33.2-microsoft-standard-WSL2 (Windows 11 + WSL2)
  • Application: LiteLLM (Python/uvicorn) — known to create zombie Prisma processes (Zombie process: Prisma, connection to database interrupted BerriAI/litellm#14739), but the containerd-shim should still handle PID 1 death gracefully regardless of the application behavior.
  • VM-side containerd/dockerd logs were lost on restart (Docker Desktop VM logs are ephemeral), so the exact moment of PID 1 death is not captured — only the aftermath is observable.

Related issues

Activity

  1. ThePlenkov commented on Jul 25, 2026

    @ThePlenkov
    Author

    The daemon-side behavior (blocking indefinitely on API calls when a shim is unresponsive) is tracked separately in moby/moby#53189.

  2. ningmingxiao commented on Jul 25, 2026

    @ningmingxiao
    Contributor

    can you kill -10 shimpid ? It will print stack in containerd log @ThePlenkov
    and can you see shim still have child process (may be in zombie status )?

  3. ThePlenkov commented on Jul 25, 2026

    @ThePlenkov
    Author

    Thanks for the suggestion. A few clarifications:

    1. I already tried on the shim PIDs (not -10), and it crashed Docker Desktop entirely. This is documented in my internal drill — the SIGHUP to containerd was a mistake that forced a manual restart. I'm hesitant to try additional signals without understanding what they do.

    2. I verified the shims had ZERO children (not zombie children) via . The output showed for all 4 shims. If there were zombie children, they would have appeared in that list (zombie processes still have PIDs). The shim was truly orphaned.

    3. The incident is already resolved — Docker Desktop was restarted, and the affected containers are now removed. I cannot reproduce the shim state to try at this time.

    If this happens again, I can try to capture the stack trace — but given that crashed Docker Desktop, I'd want to understand what does differently before risking another crash. Is there documentation on what signals containerd-shim handles gracefully?

  4. self-assigned this
    on Jul 28, 2026
  5. ningmingxiao commented on Jul 28, 2026

    @ningmingxiao
    Contributor

    can you add some log reproduce it looks like event is lost.
    "log.L.Warnf("event with pid %d status:%d may be lost", exitEvt.Pid, exitEvt.Status) "

    containerd/sys/reaper/reaper_unix.go

    func Reap() error {
    	now := time.Now()
    	exits, err := reap(false)
    	for _, e := range exits {
    		done := Default.notify(runc.Exit{
    			Timestamp: now,
    			Pid:       e.Pid,
    			Status:    e.Status,
    		})
    
    		select {
    		case <-done:
    		case <-time.After(1 * time.Second):
    			log.L.Warnf("event with pid %d status:%d may be lost", exitEvt.Pid, exitEvt.Status)
    		}
    	}
    	return err
    }
    

    @ThePlenkov

  6. ThePlenkov commented on Jul 28, 2026

    @ThePlenkov
    Author

    that's difficult for now - i will if i catch it again

  7. fuweid commented on Jul 29, 2026

    @fuweid
    Member

    Hi @ThePlenkov if you have leaky shim as you described, could you please dump shim stack like this? thanks

    # terminal 1
    $ sudo strace -f -y -e trace=write -e write=2 -s 20000000 -p $<SHIM-PID>
    # terminal 2 - goroutine dump will show in the terminal 1
    $ sudo kill -USR1 $<SHIM-PID>
  8. added
    kind/resource-leak
    on Aug 27, 2026
  9. TzachiSh commented on Sep 21, 2026

    @TzachiSh

    Confirming this on the same versions, with an extra data point that isolates the runtime as the variable.

    Affected host: containerd v2.2.5, runc 1.3.6, Docker 29.6.1, kernel 6.12.94, Debian 13.

    Symptom, matching the report exactly. Two containers (GPU inference servers) entered the state independently, ~2.5h apart. Both showed Up N hours (unhealthy) in docker ps while their main process was a zombie:

    PID 2981658  PPID 2981630  Zsl  1-02:52:30  [vllm] <defunct>
    PID 3153158  PPID 3153128  Zsl  1-00:14:29  [vllm] <defunct>
    

    Every container-scoped daemon call blocked or failed while the daemon itself stayed responsive for other containers (docker ps, docker version, and inspect on unaffected containers all returned normally):

    • docker restart → container <id> PID <pid> is zombie and can not be killed
    • docker start → error during connect: Post ".../start" after a long hang
    • docker rm -f → returned nothing, container remained
    • docker inspect on the affected container → hung
    • docker compose up -d → reported Starting, container stayed Exited

    Recovery confirmed as described. kill -9 on the two shim PIDs (the PPID column above, not the zombies) cleared it. The zombies were reparented to PID 1 and, importantly, remained as zombies afterwards — but the daemon immediately regained control: both containers became removable and recreated cleanly on the next compose up. So the stuck state is the shim, not the zombie itself.

    The part that may help narrow it: we run the identical workload and image on three hosts, and only the 2.2.5 / 1.3.6 host is affected.

    affected host host B host C
    containerd v2.2.5 v2.2.4 v2.2.4
    runc 1.3.6 1.3.5 1.3.5
    docker 29.6.1 29.5.3 29.5.2
    nvidia-container-toolkit 1.19.1 1.18.2 1.19.1
    kernel 6.12.94 6.12.90 6.1.0-30
    application version identical identical identical
    uptime / occurrences 6 days, 2 occurrences 6 weeks, none 16 weeks, none

    Host C shares the NVIDIA container toolkit version with the affected host and is unaffected, and the two unaffected hosts run different kernels from each other, so in our fleet neither the toolkit nor the kernel tracks the failure. The container runtime versions are the only factor that does.

    Trigger, as far as we can tell: in both cases the container's PID 1 had died after its own child process exited unexpectedly (the application's engine subprocess crashed with no traceback). So the preceding condition was an abnormal PID 1 exit, consistent with the "crash/OOM" framing in the original report. The application crash itself is a separate problem on our side; what this issue costs us is that a container that would otherwise be restarted by its restart policy instead became permanently unmanageable until manual intervention, and stayed that way for 26 hours before anyone noticed.

    Happy to collect anything specific from the affected host while it is still on these versions — we are about to pin it back to 2.2.4 / 1.3.5, so if a maintainer wants a shim stack dump, /proc/<shim>/stack, or goroutine dump from a live occurrence, say so and we will hold off.

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

Metadata

Metadata

Assignees

Labels

area/runtimekind/bugkind/resource-leak

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions