Skip to content

storage/stdout: nil-check Cpu, Network, and Memory stats#3917

Merged
dims merged 2 commits into
google:masterfrom
locker95:fix/stdout-storage-nil-panic
Jul 20, 2026
Merged

storage/stdout: nil-check Cpu, Network, and Memory stats#3917
dims merged 2 commits into
google:masterfrom
locker95:fix/stdout-storage-nil-panic

Conversation

@locker95

Copy link
Copy Markdown
Contributor

Problem

With -storage_driver=stdout, cAdvisor panics:

panic: runtime error: invalid memory address or nil pointer dereference
...
stdout.(*stdoutStorage).containerStatsToValues
    stdout.go:133

Line 133 is stats.Network.RxBytes. After the model change, Cpu, Network, and Memory on ContainerStats are pointers and may be nil for some containers. The stdout driver still treated them as values.

Fix

  • Guard CPU and network fields in containerStatsToValues
  • Guard memory fields in memoryStatsToValues
  • Add a unit test that used to panic (Cpu set, Network/Memory nil)

Test

cd cmd && go test ./internal/storage/stdout/ -count=1

Fixes #3911

ContainerStats fields for Cpu, Network, and Memory are pointers and
are often unset for some containers. The stdout driver always
dereferenced them, which panics as soon as Network is missing
(reproduced with -storage_driver=stdout).

Skip optional sections when the corresponding pointer is nil.

Fixes google#3911

Signed-off-by: Dean Chen <862469039@qq.com>
@google-cla

google-cla Bot commented Jul 20, 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.

@locker95

Copy link
Copy Markdown
Contributor Author

cla: yes

@locker95

Copy link
Copy Markdown
Contributor Author

I have signed the Google CLA with this GitHub account (locker95) and authorized email 862469039@qq.com.

cla: yes

Please recheck.

Signed-off-by: Dean Chen <862469039@qq.com>
@dims
dims merged commit 6a0c4f2 into google:master Jul 20, 2026
15 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.

Panic when using stdout storage driver

2 participants