Skip to content

CRI ContainerStatus/ExecSync hang and delayed sandbox teardown after VFIO/IOMMU device-pod deletion #13814

Open

Description

@tdabasinskas

Description

After moving from containerd v2.2.5 to v2.3.2 (via RKE2 v1.35.6+rke2r1 → v1.36.2+rke2r1, runc unchanged at v1.4.2), nodes that run short-lived pods with VFIO/IOMMU PCI passthrough start to degrade once such a pod is deleted.

containerd itself stays up and responsive: crictl version and crictl ps return immediately and list the running containers. But the kubelet's CRI calls for the affected pod (ContainerStatus, ExecSync) return rpc error: code = Canceled desc = context canceled or DeadlineExceeded, and containerd is slow to finish the sandbox teardown (several seconds to tens of seconds between shim disconnected and Ensure that sandbox ... cleanup successfully). After that the node stops creating new sandboxes while still reporting Ready. Restarting the runtime clears the state, but it returns the next time one of these device pods is deleted.

This did not happen on containerd v2.2.5 with the same workloads, kernel, and runc.

The symptoms resemble #11674 (a container left stuck in runc init where cleanup never completes after the shim disconnects), possibly aggravated by #10583 (a blocked call serializing other requests). The difference here is that the trigger is the deletion/teardown of an already-running VFIO passthrough pod, and the behavior is a regression that appears specifically on v2.3.2.

Observed under RKE2 (rancher/rke2#10860); RKE2 maintainers confirmed they do not modify containerd and asked us to report it here.

Steps to reproduce the issue

  1. Run containerd v2.3.2 under kubelet with cgroup v2, SystemdCgroup=true, runtime io.containerd.runc.v2, runc v1.4.2.
  2. Run pods that pass a PCI device through with VFIO/IOMMU, created and deleted frequently.
  3. Delete one of those pods.
  4. The kubelet's ContainerStatus/ExecSync for that pod return context canceled / DeadlineExceeded, the sandbox cleanup for it lags, and the node stops creating new sandboxes, while crictl against the same socket still responds normally.

Describe the results you received and expected

Received: the runtime completes teardown very slowly for the deleted VFIO pod, specific CRI calls for it time out, and the node stops starting new pods until the runtime is restarted.

Expected: teardown completes promptly and the node keeps creating pods, as it did on containerd v2.2.5.

What version of containerd are you using?

containerd v2.3.2

Any other relevant information

$ runc --version
runc version 1.4.2
commit: v1.4.2-0-gc241c0bb
spec: 1.3.0
go: go1.25.10 X:boringcrypto
$ uname -a
Linux <node> 5.15.0-185-generic #195-Ubuntu SMP Fri Jun 19 17:11:50 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
# Ubuntu 22.04 LTS

crictl remained responsive on affected nodes (returned RuntimeVersion: v2.3.2-k3s2 and listed ~26-30 running containers with no delay), so the containerd socket itself was not down.

Show configuration if it is related to CRI plugin.

Default RKE2 CRI configuration, cgroup v2:

defaultRuntimeName: "runc"
runtimeType:        "io.containerd.runc.v2"
SystemdCgroup:      true
snapshotter:        overlayfs (default)
containerdEndpoint: /run/k3s/containerd/containerd.sock

No custom runtime handlers beyond the default runc (and the standard Windows runhcs entry). Full kubelet and containerd logs covering the onset are available on request.

Activity

  1. added
    area/cri
    on Jul 20, 2026
  2. ningmingxiao commented on Jul 20, 2026

    @ningmingxiao
    Contributor

    can you kill -10 pidof containerd will print containerd stack at /tmp/ dir when exec timeout ? @tdabasinskas

  3. tdabasinskas commented on Jul 21, 2026

    @tdabasinskas
    Author

    can you kill -10 pidof containerd will print containerd stack at /tmp/ dir when exec timeout ? @tdabasinskas

    Thanks. I sent SIGUSR1 to containerd on two affected nodes while they were degraded (a ContainerStatus call had returned context canceled about a minute earlier). The dumps show a large, persistent goroutine leak rather than a momentary block.

    On both nodes, roughly two thirds to four fifths of all goroutines are stuck, and they have been stuck for about 47 hours, which lines up with the last runtime restart on those nodes:

    • node A: 296 of 448 goroutines blocked >= 100 min (longest 2816 min)
    • node B: 350 of 437 goroutines blocked >= 100 min (longest 2812 min)

    They cluster in the same task-exit / shim-wait / container-IO paths on both nodes (counts from node A):

    43  core/runtime/v2.loadShim.func3                         [IO wait]
    41  client.(*task).Wait.func1                              [select]
    38  internal/cri/io.(*ContainerIO).Pipe                    [IO wait]
    37  internal/cri/io.NewCRILogger.func1                     [select]
    25  internal/cri/server.(*criService).startContainerExitMonitor.func1
    24  internal/cri/server.(*criService).createContainerLoggers.func2  [chan receive]
    24  ttrpc.(*Client).run                                    [IO wait]
    16  internal/cri/server.(*criSandboxService).WaitSandbox.func1
    16  internal/cri/server.(*criService).startSandboxExitMonitor.func1
    14  internal/cri/server/podsandbox.(*Controller).RecoverContainer.func2
    

    The task.Wait goroutines are all blocked in the ttrpc call to the shim, waiting for a task-exit that never arrives:

    goroutine 485 [select, 2816 minutes]:
    github.com/containerd/ttrpc.(*Client).dispatch(...)
            vendor/github.com/containerd/ttrpc/client.go:546
    github.com/containerd/containerd/api/runtime/task/v3.(*ttrpctaskClient).Wait(...)
            vendor/.../api/runtime/task/v3/shim_ttrpc.pb.go:273
    github.com/containerd/containerd/v2/core/runtime/v2.(*shimTask).Wait(...)
            core/runtime/v2/shim.go:793
    github.com/containerd/containerd/v2/plugins/services/tasks.(*local).Wait(...)
            plugins/services/tasks/local.go:674
    github.com/containerd/containerd/v2/client.(*task).Wait.func1()
            client/task.go:350
    

    The matching ContainerIO.Pipe / loadShim goroutines are blocked reading the container fifos:

    goroutine 452 [IO wait, 2816 minutes]:
    ...
    github.com/containerd/fifo.(*fifo).Read(...)
    

    So it looks like the shims for these (VFIO/IOMMU device) pods never report their task exiting, and containerd's per-container exit monitors, log pipes, and task.Wait calls leak and never return. The RecoverContainer goroutines are interesting: they suggest that after a runtime restart, recovery re-attaches to these containers and gets stuck again, which matches what we see operationally (a restart clears it, then it comes back). The device path here goes through CDI (container-device-interface/pkg/cdi shows up in the frames).

    containerd.849010.stacks.log

  4. tdabasinskas commented on Jul 21, 2026

    @tdabasinskas
    Author

    Is it possible it can be related to #12714 ("Update OOMKilled event handling"), which is in 2.3.x but not in 2.2.5?

    It added a cg2oom.Stop() in the shim's handleProcessExit (cmd/containerd-shim-runc-v2/task/service.go) before s.send(TaskExit), on the shim's single processExits goroutine. Stop() blocks on <-w.errCh waiting for the per-container OOM watcher to return. If that does not return, the shim never publishes the exit, which would leave client task.Wait, the container IO fifos, and the CRI exit monitors all stuck, matching the goroutine dump above. In 2.2.5 the exit was sent immediately and internal/oom did not exist.

  5. ningmingxiao commented on Jul 21, 2026

    @ningmingxiao
    Contributor

    from stack I can't find exec or get ContainerStatus use much time , could you raise the concurrency level? and print stack again and grep several containers log

    goroutine 196738528 [select]:
    github.com/containerd/containerd/v2/internal/cri/server.(*criService).execInternal(0x204c42cb7688, {0x2f4b168?, 0x204c43819980?}, {0x2f69ce0, 0x204c44d036c0}, {0x204c443988c0, 0x40}, {{0x204c45c2dda0, 0x2, 0x2}, ...})
    	/go/src/github.com/containerd/containerd/internal/cri/server/container_execsync.go:229 +0xf65
    github.com/containerd/containerd/v2/internal/cri/server.(*criService).execInContainer(0x204c42cb7688, {0x2f4b168, 0x204c43819980}, {0x204c43a35200, 0x40}, {{0x204c45c2dda0, 0x2, 0x2}, {0x0, 0x0}, ...})
    	/go/src/github.com/containerd/containerd/internal/cri/server/container_execsync.go:287 +0x646
    github.com/containerd/containerd/v2/internal/cri/server.(*criService).ExecSync(0x204c42cb7688, {0x2f4b168, 0x204c43819980}, 0x204c438e5380)
    	/go/src/github.com/containerd/containerd/internal/cri/server/container_execsync.go:84 +0x2af
    github.com/containerd/containerd/v2/internal/cri/instrument.(*instrumentedService).ExecSync(0x204c43f52f10, {0x2f4b168, 0x204c43819830}, 0x204c438e5380)
    

    @tdabasinskas

  6. tdabasinskas commented on Jul 21, 2026

    @tdabasinskas
    Author

    from stack I can't find exec or get ContainerStatus use much time , could you raise the concurrency level? and print stack again and grep several containers log

    goroutine 196738528 [select]:
    github.com/containerd/containerd/v2/internal/cri/server.(*criService).execInternal(0x204c42cb7688, {0x2f4b168?, 0x204c43819980?}, {0x2f69ce0, 0x204c44d036c0}, {0x204c443988c0, 0x40}, {{0x204c45c2dda0, 0x2, 0x2}, ...})
    	/go/src/github.com/containerd/containerd/internal/cri/server/container_execsync.go:229 +0xf65
    github.com/containerd/containerd/v2/internal/cri/server.(*criService).execInContainer(0x204c42cb7688, {0x2f4b168, 0x204c43819980}, {0x204c43a35200, 0x40}, {{0x204c45c2dda0, 0x2, 0x2}, {0x0, 0x0}, ...})
    	/go/src/github.com/containerd/containerd/internal/cri/server/container_execsync.go:287 +0x646
    github.com/containerd/containerd/v2/internal/cri/server.(*criService).ExecSync(0x204c42cb7688, {0x2f4b168, 0x204c43819980}, 0x204c438e5380)
    	/go/src/github.com/containerd/containerd/internal/cri/server/container_execsync.go:84 +0x2af
    github.com/containerd/containerd/v2/internal/cri/instrument.(*instrumentedService).ExecSync(0x204c43f52f10, {0x2f4b168, 0x204c43819830}, 0x204c438e5380)
    

    @tdabasinskas

    You're right, exec and ContainerStatus aren't the slow calls. That dump has 1 ExecSync goroutine (0 min) and no long-blocked ContainerStatus. The ~47h-stuck ones are all task-exit: 41 task.Wait, 41 exit monitors, 14 RecoverContainer. The kubelet-side exec/status timeouts look downstream of the task-exit never being published.

    What do you mean by "raise the concurrency level"?

  7. ningmingxiao commented on Jul 21, 2026

    @ningmingxiao
    Contributor

    the issue describe ContainerStatus/ExecSync hang but I can't find it's hanging from the stack. task.Wait is a normal stack @tdabasinskas

  8. tdabasinskas commented on Jul 21, 2026

    @tdabasinskas
    Author

    the issue describe ContainerStatus/ExecSync hang but I can't find it's hanging from the stack. task.Wait is a normal stack @tdabasinskas

    Agreed, a blocked task.Wait on its own is a normal stack. These are different - they belong to orphaned shims. The containerd-shim-runc-v2 and its task.Wait are still alive, but the sandbox is already gone from crictl pods, and the shim's task bundle/log is deleted (its log fd points at a deleted file). So the sandbox is gone but the exit was never delivered and Wait never returned, which is not what a running container looks like.

    I tried to grab the shim's own goroutines with SIGUSR1, but for an orphaned shim the log target is already deleted, so the dump goes nowhere.

  9. ningmingxiao commented on Jul 22, 2026

    @ningmingxiao
    Contributor

    can you show the log about the leak shim's container and does the leak shim have child process? @tdabasinskas

  10. tdabasinskas commented on Jul 22, 2026

    @tdabasinskas
    Author

    can you show the log about the leak shim's container and does the leak shim have child process? @tdabasinskas

    The leaked shim has no child processes (ps --ppid <shim> returns nothing), so the container itself is gone.

    Its log lines have rotated out of the current containerd.log, but the lifecycle is in an older rotated file. containerd created the sandbox, and at exit it logged a full teardown:

    07:33  RunPodSandbox / CreateContainer
    12:37  received sandbox exit event
    12:37  shim disconnected / cleaning up after shim disconnected / cleaning up dead shim
    12:37  StopPodSandbox
    12:38  StopPodSandbox / RemovePodSandbox
    12:38  Ensure that sandbox <id> in task-service has been cleanup successfully / RemovePodSandbox
    
  11. fuweid commented on Jul 27, 2026

    @fuweid
    Member

    Hi @tdabasinskas could you please provide the detail about how to use Run pods that pass a PCI device through with VFIO/IOMMU, created and deleted frequently., like pod yaml (eg, it's using host pid namespace). I would like to reproduce it in my local env. Thanks

  12. 4 remaining items

  13. ningmingxiao commented on Jul 28, 2026

    @ningmingxiao
    Contributor

    issue #13849 looks like event is dropped (it says that docker ps show container is running)pr try to fix it https://github.com/containerd/containerd/pull/13653/changes @tdabasinskas

  14. tdabasinskas commented on Jul 28, 2026

    @tdabasinskas
    Author

    issue #13849 looks like event is dropped (it says that docker ps show container is running)pr try to fix it https://github.com/containerd/containerd/pull/13653/changes @tdabasinskas

    That fits. If Reap() drops the exit event when processExits takes more than 1s, then #12714's cg2oom.Stop is exactly the kind of thing that can push processExits past that threshold on teardown, since it blocks on the OOM watcher.

    I guess that would explain why we see it on 2.3.2 and not 2.2.5, and why the shim ends up alive with no children and no task-exit. #13849 looks like the same drop reached through lock contention instead. Queuing the events in #13653 so a slow consumer can't drop them looks like it would cover our case too.

  15. fuweid commented on Jul 29, 2026

    @fuweid
    Member

    @tdabasinskas did you use share-pid-namespace in pod level? I run 10 containers with oom-killed and a lot of exec requests.
    I can reproduce kind of dead-lock issue because killAll invokes sub process and wait for the event.

    if runc.ShouldKillAllOnExit(s.context, c.Bundle) {

    If the event queue is full (current is 32), it will be deadlock like this. (after 10-20 minutes, it will be gone)

    goroutine 14 [chan receive]:
    github.com/containerd/containerd/v2/pkg/sys/reaper.(*Monitor).Wait(0xc13470, 0x187c3755c000, 0x187c37038e70)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/pkg/sys/reaper/reaper_unix.go:116 +0x51
    github.com/containerd/go-runc.(*Runc).cmdOutput(0x187c36d72090, 0x187c3755c000, 0x1, 0x0)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/vendor/github.com/containerd/go-runc/runc.go:835 +0x11b
    github.com/containerd/go-runc.(*Runc).runOrError(0x187c36d72090?, 0x8bdfd0?)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/vendor/github.com/containerd/go-runc/runc.go:810 +0x1ad
    github.com/containerd/go-runc.(*Runc).Kill(0x187c36d72090, {0x8bdfd0, 0x187c36e3a2a0}, {0x187c36e164c0, 0x40}, 0x9?, 0x187c373e5ce0?)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/vendor/github.com/containerd/go-runc/runc.go:399 +0x375
    github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/process.(*Init).KillAll(0x187c370126e0, {0x8bdfd0?, 0x187c36e3a2a0?})
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/process/init.go:379 +0xf0
    github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/task.(*service).handleInitExit(0x187c36d9e630, {{0xc2926404a009f29d, 0x6d7c807a, 0xc152c0}, 0x26747d, 0x89}, 0x187c36d36900, 0x187c370126e0)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/task/service.go:728 +0x97
    github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/task.(*service).processExits(0x187c36d9e630)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/task/service.go:692 +0x5e5
    created by github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/task.NewTaskService in goroutine 1
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/task/service.go:91 +0x379
    
    
    

    If you can share more pattern about your pod yaml, it will be helpful. thanks

  16. tdabasinskas commented on Jul 29, 2026

    @tdabasinskas
    Author

    @tdabasinskas did you use share-pid-namespace in pod level? I run 10 containers with oom-killed and a lot of exec requests. I can reproduce kind of dead-lock issue because killAll invokes sub process and wait for the event.

    containerd/cmd/containerd-shim-runc-v2/task/service.go

    Line 725 in 3845698

    if runc.ShouldKillAllOnExit(s.context, c.Bundle) {
    If the event queue is full (current is 32), it will be deadlock like this. (after 10-20 minutes, it will be gone)

    goroutine 14 [chan receive]:
    github.com/containerd/containerd/v2/pkg/sys/reaper.(*Monitor).Wait(0xc13470, 0x187c3755c000, 0x187c37038e70)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/pkg/sys/reaper/reaper_unix.go:116 +0x51
    github.com/containerd/go-runc.(*Runc).cmdOutput(0x187c36d72090, 0x187c3755c000, 0x1, 0x0)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/vendor/github.com/containerd/go-runc/runc.go:835 +0x11b
    github.com/containerd/go-runc.(*Runc).runOrError(0x187c36d72090?, 0x8bdfd0?)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/vendor/github.com/containerd/go-runc/runc.go:810 +0x1ad
    github.com/containerd/go-runc.(*Runc).Kill(0x187c36d72090, {0x8bdfd0, 0x187c36e3a2a0}, {0x187c36e164c0, 0x40}, 0x9?, 0x187c373e5ce0?)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/vendor/github.com/containerd/go-runc/runc.go:399 +0x375
    github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/process.(*Init).KillAll(0x187c370126e0, {0x8bdfd0?, 0x187c36e3a2a0?})
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/process/init.go:379 +0xf0
    github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/task.(*service).handleInitExit(0x187c36d9e630, {{0xc2926404a009f29d, 0x6d7c807a, 0xc152c0}, 0x26747d, 0x89}, 0x187c36d36900, 0x187c370126e0)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/task/service.go:728 +0x97
    github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/task.(*service).processExits(0x187c36d9e630)
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/task/service.go:692 +0x5e5
    created by github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/task.NewTaskService in goroutine 1
    	/home/niuhechaofan/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/task/service.go:91 +0x379
    

    If you can share more pattern about your pod yaml, it will be helpful. thanks

    No shared PID namespace at pod level, and no hostPID.

    I can't share the full manifests, but the relevant traits are the ones already mentioned: a single container running a VM (so PID 1 has child processes for KillAll to reap), cgroup v2, a memory limit so it can OOM, deleted on teardown, and an httpGet readiness probe rather than exec.

  17. fuweid commented on Jul 29, 2026

    @fuweid
    Member

    @tdabasinskas It looks odd to me. container-level pid namespace won't trigger kill-all during handling exit events because kernel will terminate all the threads or processes before sending exit event. Ideally, reading cgroup file is pretty fast. It won't block the whole progress. If you have chance, could you please dump goroutine stack like this? #13849 (comment) thanks (if there is any related dmesg information, that will help too)

  18. tdabasinskas commented on Jul 29, 2026

    @tdabasinskas
    Author

    @tdabasinskas It looks odd to me. container-level pid namespace won't trigger kill-all during handling exit events because kernel will terminate all the threads or processes before sending exit event. Ideally, reading cgroup file is pretty fast. It won't block the whole progress. If you have chance, could you please dump goroutine stack like this? #13849 (comment) thanks (if there is any related dmesg information, that will help too)

    shim-2770534-goroutines.txt

  19. fuweid commented on Jul 29, 2026

    @fuweid
    Member

    It looks like it was truncated.

    sudo strace -f -y -e trace=write -e write=2 -s $<SIZE> -p $<SHIM-PID>

    if you see anything like this goro"..., it means you need to increase '$SIZE'.

    [pid  9460] write(7</run/containerd/io.containerd.runtime.v2.task/moby/f2231ab4be0b297655c9ef04c7d8f1889a94a7351dba8243867c1aa31b313005/log>, "time=\"2026-07-29T08:14:47.791079140-04:00\" level=info msg=\"=== BEGIN goroutine stack dump ===\\ngoroutine 28 [running]:\\ngithub.com/containerd/containerd/v2/pkg/shim.dumpStacks(0xc000200540)\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:492 +0x4f\\ngithub.com/containerd/containerd/v2/pkg/shim.serve.func2()\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:476 +0x38\\ncreated by github.com/containerd/containerd/v2/pkg/shim.serve in goroutine 1\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:474 +0x471\\n\\ngoroutine 1 [select, 9309 minutes]:\\ngithub.com/containerd/containerd/v2/pkg/shim.reap({0x924450, 0xc0002041e0}, 0xc000200540, 0xc000023f10)\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim_unix.go:77 +0xc9\\ngithub.com/containerd/containerd/v2/pkg/shim.serve({0x924450, 0xc0002041e0}, 0xc000204780, 0xc000023f10, 0xc000202258, {0x0, 0x0})\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:481 +0x50b\\ngithub.com/containerd/containerd/v2/pkg/shim.run({0x924450, 0xc0001ea210}, {0x924418, 0xc000030850}, {0x60?, 0x8?, 0x3?})\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:422 +0x1d65\\ngithub.com/containerd/containerd/v2/pkg/shim.Run({0x9243e0, 0xc165a0}, {0x924418, 0xc000030850}, {0x0, 0x0, 0xc000002380?})\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:198 +0x12c\\nmain.main()\\n\\t/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/main.go:30 +0x51\\n\\ngoroutine 7 [chan receive]:\\ngithub.com/containerd/containerd/v2/pkg/shim.setRuntime.func1()\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:164 +0x5a\\ncreated by github.com/containerd/containerd/v2/pkg/shim.setRuntime in goroutine 1\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:163 +0x25\\n\\ngoroutine 9 [syscall]:\\nos/signal.signal_recv()\\n\\t/usr/local/go/src/runtime/sigqueue.go:152 +0x29\\nos/signal.loop()\\n\\t/usr/local/go/src/os/signal/signal_unix.go:23 +0x13\\ncreated by os/signal.Notify.func1.1 in goro"..., 15257) = 15257
    
  20. tdabasinskas commented on Jul 29, 2026

    @tdabasinskas
    Author

    It looks like it was truncated.

    sudo strace -f -y -e trace=write -e write=2 -s $<SIZE> -p $<SHIM-PID>

    if you see anything like this goro"..., it means you need to increase .

    [pid  9460] write(7</run/containerd/io.containerd.runtime.v2.task/moby/f2231ab4be0b297655c9ef04c7d8f1889a94a7351dba8243867c1aa31b313005/log>, "time=\"2026-07-29T08:14:47.791079140-04:00\" level=info msg=\"=== BEGIN goroutine stack dump ===\\ngoroutine 28 [running]:\\ngithub.com/containerd/containerd/v2/pkg/shim.dumpStacks(0xc000200540)\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:492 +0x4f\\ngithub.com/containerd/containerd/v2/pkg/shim.serve.func2()\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:476 +0x38\\ncreated by github.com/containerd/containerd/v2/pkg/shim.serve in goroutine 1\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:474 +0x471\\n\\ngoroutine 1 [select, 9309 minutes]:\\ngithub.com/containerd/containerd/v2/pkg/shim.reap({0x924450, 0xc0002041e0}, 0xc000200540, 0xc000023f10)\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim_unix.go:77 +0xc9\\ngithub.com/containerd/containerd/v2/pkg/shim.serve({0x924450, 0xc0002041e0}, 0xc000204780, 0xc000023f10, 0xc000202258, {0x0, 0x0})\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:481 +0x50b\\ngithub.com/containerd/containerd/v2/pkg/shim.run({0x924450, 0xc0001ea210}, {0x924418, 0xc000030850}, {0x60?, 0x8?, 0x3?})\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:422 +0x1d65\\ngithub.com/containerd/containerd/v2/pkg/shim.Run({0x9243e0, 0xc165a0}, {0x924418, 0xc000030850}, {0x0, 0x0, 0xc000002380?})\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:198 +0x12c\\nmain.main()\\n\\t/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/main.go:30 +0x51\\n\\ngoroutine 7 [chan receive]:\\ngithub.com/containerd/containerd/v2/pkg/shim.setRuntime.func1()\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:164 +0x5a\\ncreated by github.com/containerd/containerd/v2/pkg/shim.setRuntime in goroutine 1\\n\\t/go/src/github.com/containerd/containerd/pkg/shim/shim.go:163 +0x25\\n\\ngoroutine 9 [syscall]:\\nos/signal.signal_recv()\\n\\t/usr/local/go/src/runtime/sigqueue.go:152 +0x29\\nos/signal.loop()\\n\\t/usr/local/go/src/os/signal/signal_unix.go:23 +0x13\\ncreated by os/signal.Notify.func1.1 in goro"..., 15257) = 15257
    

    shim-2770534-full.txt

  21. fuweid commented on Jul 29, 2026

    @fuweid
    Member

    Thanks.

    **goroutine 37 [chan receive, 33108 minutes]:\
    github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/task.(*service).processExits(0x193a2a39c000)\
    \	/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/task/service.go:662 +0x6c\
    created by github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/task.NewTaskService in goroutine 1\
    \	/go/src/github.com/containerd/containerd/cmd/containerd-shim-runc-v2/task/service.go:89 +0x305\
    \**

    The shim looks leaky to me because there is no Wait handler. I will update if I get something

  22. ningmingxiao commented on Jul 29, 2026

    @ningmingxiao
    Contributor

    can you see the container is still runing from ctr/crictl ? @tdabasinskas

  23. ningmingxiao commented on Jul 29, 2026

    @ningmingxiao
    Contributor

    I guess processExits() receive event but because of unknow reason the event is dropped.

    func (s *service) processExits() {
    	for e := range s.ec {
    // then event is dropped
    

    @fuweid @tdabasinskas

  24. fuweid commented on Jul 29, 2026

    @fuweid
    Member

    I guess processExits() receive event but because of unknow reason the event is dropped.

    Personally, I don't want to guess here and I don't think there is missing event. containerd-cri doesn't depend on exit event. it's using Wait api to get exit event.

  25. tdabasinskas commented on Jul 30, 2026

    @tdabasinskas
    Author

    can you see the container is still runing from ctr/crictl ? @tdabasinskas

    No, the container is completely gone. ctr tasks ls, ctr containers ls, and crictl pods/ps all show nothing for it

  26. fuweid commented on Aug 3, 2026

    @fuweid
    Member

    Currently I can only reproduce that the kernel needs some time to unmap and unpin the VFIO memory after SIGKILL. I think this delay itself is expected. In my test, the delay increases with the amount of pinned mappings.

    For a container-level PID namespace, the container init process cannot fully exit before all processes and threads in this PID namespace are gone. Only after this kernel cleanup is finished, containerd-shim can receive the process exit and generate the TaskExit event.

    @tdabasinskas Could you please reproduce it again in your environment and collect the following information for one affected pod when you have chance?

    1. Full containerd debug logs, starting before the pod deletion and continuing until the problem happens. Please include the exact pod ID, container ID and shim

    2. How many requests containerd received for this pod during this time, especially ExecSync, ContainerStatus, StopContainer, StopPodSandbox and RemovePodSandbox. And if there is any restart operation for containerd

    3. Whether there are any processes or threads in D state during the teardown:

    ps -eLo pid,tid,ppid,stat,wchan:32,cmd

    1. If a D-state process exists, please also collect:

    cat /proc//stack
    cat /proc//status

    1. The process tree under the shim while the problem is happening:

    ps -eLo pid,tid,ppid,stat,wchan:32,cmd

    1. A goroutine dump from the affected shim at the same time.

    2. Any related kernel messages:

    dmesg -T | grep -Ei 'vfio|iommu|reset|hung task|blocked for more than'

    The main thing I want to confirm is: does TaskExit not appear because the container init is still exiting inside the kernel, or has the init process already disappeared but the exit event or shim shutdown is lost?

    Thanks.

  27. tdabasinskas commented on Aug 3, 2026

    @tdabasinskas
    Author

    Currently I can only reproduce that the kernel needs some time to unmap and unpin the VFIO memory after SIGKILL. I think this delay itself is expected. In my test, the delay increases with the amount of pinned mappings.

    For a container-level PID namespace, the container init process cannot fully exit before all processes and threads in this PID namespace are gone. Only after this kernel cleanup is finished, containerd-shim can receive the process exit and generate the TaskExit event.

    @tdabasinskas Could you please reproduce it again in your environment and collect the following information for one affected pod when you have chance?

    1. Full containerd debug logs, starting before the pod deletion and continuing until the problem happens. Please include the exact pod ID, container ID and shim
    2. How many requests containerd received for this pod during this time, especially ExecSync, ContainerStatus, StopContainer, StopPodSandbox and RemovePodSandbox. And if there is any restart operation for containerd
    3. Whether there are any processes or threads in D state during the teardown:

    ps -eLo pid,tid,ppid,stat,wchan:32,cmd

    1. If a D-state process exists, please also collect:

    cat /proc//stack
    cat /proc//status

    1. The process tree under the shim while the problem is happening:

    ps -eLo pid,tid,ppid,stat,wchan:32,cmd

    1. A goroutine dump from the affected shim at the same time.
    2. Any related kernel messages:

    dmesg -T | grep -Ei 'vfio|iommu|reset|hung task|blocked for more than'

    The main thing I want to confirm is: does TaskExit not appear because the container init is still exiting inside the kernel, or has the init process already disappeared but the exit event or shim shutdown is lost?

    Thanks.

    I ran one controlled teardown of an idle viommu runner (SIGKILL via delete) and it came out clean: the shim exited, the task was removed from ctr, there was no D-state on the container, and no hung-task or stuck-VFIO in dmesg. So a normal teardown works fine, and the leak looks intermittent, I couldn't reproduce it on demand.

    These are production nodes, so I'm limited in how much teardown experimentation I can do, and I can't reliably reproduce it here. I think we've shared what we can from our side: the containerd and shim goroutine dumps, the 2.2.5 to 2.3.2 boundary, and the leaked-shim state (idle processExits, container already gone from ctr/crictl).

    If a fix lands and goes into the next version of rke2, we're glad to run it and confirm the leaked shims stop accumulating. Thanks for digging into this!

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

Metadata

Metadata

Assignees

Labels

area/criarea/runtimekind/bug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions