Skip to content

runsc: fix start of a sub-container in a restoring sandbox - #16744

Merged
EtiennePerot merged 3 commits into
gvisor:masterfrom
jingyugao:fix/start-subcontainer-nil-restore-reply
Dec 1, 2026
Merged

EtiennePerot merged 3 commits into
gvisor:masterfrom
jingyugao:fix/start-subcontainer-nil-restore-reply

Conversation

@jingyugao

Copy link
Copy Markdown
Contributor

StartSubcontainer translates runsc start on a restoring sandbox to RestoreSubcontainer (e7b87ed) and passes a nil reply. Since a49825f added RestoreReply, RestoreSubcontainer writes reply.KernelStarted, so the translated call panics and the sandbox exits:

panic: runtime error: invalid memory address or nil pointer dereference
gvisor.dev/gvisor/runsc/boot.(*containerManager).RestoreSubcontainer(0x..., 0x..., 0x0)
	runsc/boot/controller.go
gvisor.dev/gvisor/runsc/boot.(*containerManager).StartSubcontainer(...)

The caller sees urpc method "containerManager.StartSubcontainer" failed: EOF: the sandbox exited before the container started.

Change

StartSubcontainer now passes its reply through and returns it to Sandbox.StartSubcontainer.

Avoiding the panic alone is not enough. When this start restores the last container, the sandbox has to switch from the lifecycle CPU limit to the application CPU limit, and only the reply tells the caller that this happened. Without it, the application keeps running under the higher lifecycle limit. The caller now applies the limit in the same way as Sandbox.RestoreSubcontainer.

Testing

Added TestMultiContainerCheckpointRestoreStartSubcontainer. It restores the root container, calls Start on the sub-container, and then checks that the sub-container works and that cpu.max holds the application limit.

Code Result
Without the change Fails: the sandbox exits with EOF
Reply passed through, limit not applied Fails: cpu.max is 100000 100000, want 25000 100000
This change Passes

I ran this test and TestMultiContainerCheckpointRestore locally on the KVM platform only, because Systrap fails on my WSL2 host (failed to install seccomp notify rules: device or resource busy). nogo passes for runsc/boot, runsc/sandbox and the runsc/container tests. I hit the panic on a Kubernetes node running Systrap, where this path is reached by a pod restore.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CXi3Tj8W2ypHic4RL4MAwa

@google-cla

google-cla Bot commented Oct 30, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@tjq

tjq commented Nov 5, 2026

Copy link
Copy Markdown

hit this independently on release-20261102.0 with plain runsc (no containerd), repro in #16945

@shayonj shayonj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude on behalf of shayon

@shayonj

shayonj commented Nov 25, 2026

Copy link
Copy Markdown
Member

Also, please check out the recently updated contributor guidelines around DCO. Thanks!

@jingyugao
jingyugao force-pushed the fix/start-subcontainer-nil-restore-reply branch from 2398b6e to 4cfa07a Compare November 25, 2026 14:22
Comment thread runsc/sandbox/sandbox.go Resolved
@ayushr2
ayushr2 requested a review from EtiennePerot November 30, 2026 00:00
@ayushr2

ayushr2 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

@jingyugao thanks for the fix, can you rebase?

StartSubcontainer translates `runsc start` on a restoring sandbox to
RestoreSubcontainer, and passes a nil reply. Since a49825f added
RestoreReply, RestoreSubcontainer writes to that reply, so the translated
call panics with a nil pointer dereference and the sandbox exits.

Pass the reply through and return it to the caller. The caller needs it:
when this start restores the last container, the sandbox must switch from
its lifecycle CPU limit to the application CPU limit. Otherwise the
application keeps running under the higher lifecycle limit.

Signed-off-by: gaojingyu <[email protected]>
A subcontainer can retain the CPU limit that was in effect when it was
created. When its start or restore starts the restored kernel, apply the
current application limit under the root container's state-file lock
to serialize the change with runsc update.

Exercise both paths by updating the root quota after creating the
subcontainer and checking cpu.max after restore completes.

Signed-off-by: gaojingyu <[email protected]>
@jingyugao
jingyugao force-pushed the fix/start-subcontainer-nil-restore-reply branch from 7b25196 to 9ec43b5 Compare November 30, 2026 02:00
Comment thread runsc/container/container.go Resolved
EtiennePerot
EtiennePerot previously approved these changes Nov 30, 2026
@EtiennePerot
EtiennePerot enabled auto-merge (squash) November 30, 2026 20:05
shayonj
shayonj previously approved these changes Nov 30, 2026
auto-merge was automatically disabled December 1, 2026 05:19

Head branch was pushed to by a user without write access

@jingyugao
jingyugao dismissed stale reviews from shayonj and EtiennePerot via 3c64543 December 1, 2026 05:19
@EtiennePerot
EtiennePerot enabled auto-merge (squash) December 1, 2026 05:44
@EtiennePerot
EtiennePerot merged commit 61d3a87 into gvisor:master Dec 1, 2026
22 of 31 checks passed
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.

6 participants