Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: panic when stop containers in compose #917

Closed
sko00o opened this issue Mar 6, 2023 · 4 comments
Closed

[Bug]: panic when stop containers in compose #917

sko00o opened this issue Mar 6, 2023 · 4 comments
Labels
bug An issue with the library

Comments

@sko00o
Copy link
Contributor

sko00o commented Mar 6, 2023

Testcontainers version

0.18.0

Using the latest Testcontainers version?

Yes

Host OS

MacOS

Host arch

x86

Go version

1.18.10

Docker version

Client:
 Cloud integration: v1.0.22
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:46:56 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:43:56 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.7.1)
  compose: Docker Compose (Docker Inc., v2.2.3)
  scan: Docker Scan (Docker Inc., v0.16.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 14
 Server Version: 20.10.12
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc version: v1.0.2-0-g52b36a2
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.10.76-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 4.821GiB
 Name: docker-desktop
 ID: Z4EU:VNSP:4SAB:7KHL:Z5MW:MQI2:ZZFL:CZM3:NVOV:Z5AK:CJBA:NECN
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 47
  Goroutines: 51
  System Time: 2023-03-06T15:19:00.0879411Z
  EventsListeners: 5
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
 Live Restore Enabled: false

What happened?

I need to restart some services in my test. When I use docker compose for test , I got panic when I stop any services.

Relevant log output

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

goroutine 9 [running]:
testing.tRunner.func1.2({0x2863d20, 0x3d5d6b0})
	/Users/shank/sdk/go1.18.10/src/testing/testing.go:1389 +0x24e
testing.tRunner.func1()
	/Users/shank/sdk/go1.18.10/src/testing/testing.go:1392 +0x39f
panic({0x2863d20, 0x3d5d6b0})
	/Users/shank/sdk/go1.18.10/src/runtime/panic.go:838 +0x207
github.com/testcontainers/testcontainers-go.(*DockerContainer).Stop(0xc000298c80, {0x2e6e2a0, 0xc000062080}, 0xc000a07ef0)
	/Users/shank/Projects/testcontainers-go/docker.go:220 +0xed
github.com/testcontainers/testcontainers-go/modules/compose.TestDockerComposeAPIWithStopServices(0xc000493860)
	/Users/shank/Projects/testcontainers-go/modules/compose/compose_api_test.go:128 +0x3b0
testing.tRunner(0xc000493860, 0x2c50fe8)
	/Users/shank/sdk/go1.18.10/src/testing/testing.go:1439 +0x102
created by testing.(*T).Run
	/Users/shank/sdk/go1.18.10/src/testing/testing.go:1486 +0x35f

Additional information

I known where bug is. And I would like to fix it.

@sko00o sko00o added the bug An issue with the library label Mar 6, 2023
@mdelapenya
Copy link
Member

I known where bug is. And I would like to fix it.

Hi @sko00o feel free to submit a fix for it :) I'd like to understand better how you found if.

I can see in docker.go:L220 that there is a reference to c.Image, which could be the culprit. Why this container reference is nil?

@sko00o
Copy link
Contributor Author

sko00o commented Mar 6, 2023

The panic is because logger field is nil While calling Stop method.

@mdelapenya
Copy link
Member

The panic is because logger field is nil While calling Stop method.

Oh I see, thanks for the clarification. Will take a look at your PR tomorrow morning

@mdelapenya
Copy link
Member

Closing, as #918 was merged, thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library
Projects
None yet
Development

No branches or pull requests

2 participants