[GH-ISSUE #34] App get fatal error if container inspect fails #15

Closed
opened 2026-02-26 04:33:46 +03:00 by kerem · 1 comment
Owner

Originally created by @mageddo on GitHub (Sep 10, 2017).
Original GitHub issue: https://github.com/mageddo/dns-proxy-server/issues/34

At this line in this snippet of code

cInspection, err := cli.ContainerInspect(ctx, event.ID)
  if err != nil {
    logger.Errorf("status=inspect-error, container=%s, err=%v", cInspection.Name, err)

If the inspection get a error the application will get nil pointer when try to log the container name

Taks

💡 Fix the nil pointer
💡 add continue statement to start the next iteration

🆗

Originally created by @mageddo on GitHub (Sep 10, 2017). Original GitHub issue: https://github.com/mageddo/dns-proxy-server/issues/34 [At this line](https://github.com/mageddo/dns-proxy-server/blob/3e49e1cc06845f27d3f2443c3d053083cf1febff/src/github.com/mageddo/dns-proxy-server/events/docker/DockerEvents.go#L83) in this snippet of code ```go cInspection, err := cli.ContainerInspect(ctx, event.ID) if err != nil { logger.Errorf("status=inspect-error, container=%s, err=%v", cInspection.Name, err) ``` If the inspection get a error the application will get nil pointer when try to log the container name ### Taks :bulb: Fix the nil pointer :bulb: add continue statement to start the next iteration :ok:
kerem 2026-02-26 04:33:46 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@mageddo commented on GitHub (Sep 10, 2017):

Evidence

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

goroutine 7 [running]:
panic(0x73cb60, 0xc42000c060)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/mageddo/dns-proxy-server/events/docker.HandleDockerEvents()
	/app/src/github.com/mageddo/dns-proxy-server/events/docker/DockerEvents.go:83 +0x10bb
created by main.main
	/app/src/dns.go:121 +0x144

<!-- gh-comment-id:328359269 --> @mageddo commented on GitHub (Sep 10, 2017): Evidence ``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5147eb] goroutine 7 [running]: panic(0x73cb60, 0xc42000c060) /usr/local/go/src/runtime/panic.go:500 +0x1a1 github.com/mageddo/dns-proxy-server/events/docker.HandleDockerEvents() /app/src/github.com/mageddo/dns-proxy-server/events/docker/DockerEvents.go:83 +0x10bb created by main.main /app/src/dns.go:121 +0x144 ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/dns-proxy-server-mageddo#15
No description provided.