Skip to content

fix: prevent potential panic in Shutdown when EventsService is nil#51797

Merged
vvoland merged 1 commit intomoby:masterfrom
lujinda:fix_shutdown_panic
Jan 2, 2026
Merged

fix: prevent potential panic in Shutdown when EventsService is nil#51797
vvoland merged 1 commit intomoby:masterfrom
lujinda:fix_shutdown_panic

Conversation

@lujinda
Copy link
Contributor

@lujinda lujinda commented Dec 30, 2025

Add nil check before calling EventsService.Close() to prevent panic when daemon.EventsService is not initialized during shutdown.

- What I did

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x3eaea6d]

goroutine 1 [running, locked to thread]:
github.com/moby/moby/v2/daemon/events.(*Events).Close(...)
        /go/src/github.com/docker/docker/daemon/events/events.go:157
github.com/moby/moby/v2/daemon.(*Daemon).Shutdown(0xc000249408, {0xf4cf80, 0x4a854a0})
        /go/src/github.com/docker/docker/daemon/daemon.go:1513 +0x50d
github.com/moby/moby/v2/daemon.NewDaemon.func1()
        /go/src/github.com/docker/docker/daemon/daemon.go:914 +0x49
github.com/moby/moby/v2/daemon.NewDaemon({0xf4cff0, 0xc00037c5a0}, 0xc000536c08, 0xc00041ba40, 0xc000069220)
        /go/src/github.com/docker/docker/daemon/daemon.go:1379 +0x2be5
github.com/moby/moby/v2/daemon/command.(*daemonCLI).start(0xc00037c0f0, {0xf4cf80, 0x4a854a0})
        /go/src/github.com/docker/docker/daemon/command/daemon.go:270 +0x1075
github.com/moby/moby/v2/daemon/command.runDaemon(...)
        /go/src/github.com/docker/docker/daemon/command/docker_unix.go:13
github.com/moby/moby/v2/daemon/command.newDaemonCommand.func1(0xc0007c0008, {0xc000708180?, 0x7?, 0xa38a40?})
        /go/src/github.com/docker/docker/daemon/command/docker.go:48 +0xb3
github.com/spf13/cobra.(*Command).execute(0xc0007c0008, {0xc000052060, 0x4, 0x4})
        /go/src/github.com/docker/docker/vendor/github.com/spf13/cobra/command.go:1015 +0xb02
github.com/spf13/cobra.(*Command).ExecuteC(0xc0007c0008)
        /go/src/github.com/docker/docker/vendor/github.com/spf13/cobra/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
        /go/src/github.com/docker/docker/vendor/github.com/spf13/cobra/command.go:1071
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        /go/src/github.com/docker/docker/vendor/github.com/spf13/cobra/command.go:1064
github.com/moby/moby/v2/daemon/command.daemonRunner.Run({0xf19640?}, {0xf4cf80, 0x4a854a0})
        /go/src/github.com/docker/docker/daemon/command/docker.go:97 +0x6e
main.main()
        /go/src/github.com/docker/docker/cmd/dockerd/main.go:35 +0x119

- How I did it

- How to verify it

- Human readable description for the release notes

Prevent a potential panic on daemon shutdown after an incomplete initialization

- A picture of a cute animal (not mandatory but encouraged)

@github-actions github-actions bot added the area/daemon Core Engine label Dec 30, 2025
Add nil check before calling EventsService.Close() to prevent panic
when daemon.EventsService is not initialized during shutdown.

Signed-off-by: jinda.ljd <jinda.ljd@alibaba-inc.com>
@robmry robmry added impact/changelog kind/bugfix PR's that fix bugs labels Dec 31, 2025
@vvoland vvoland added this to the 29.2.0 milestone Jan 2, 2026
Copy link
Contributor

@vvoland vvoland left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@vvoland vvoland merged commit 92a240f into moby:master Jan 2, 2026
322 of 326 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants