compose icon indicating copy to clipboard operation
compose copied to clipboard

Removing a container with piped yes causes a panic runtime error

Open jgeiger-trane opened this issue 3 years ago • 0 comments

Description

Removing a container using yes | docker-compose rm redis causes the application to crash with a panic runtime error.

Steps to reproduce the issue:

  1. Add docker-compose.yml
version: "3.9"
services:
  redis:
    image: "redis:alpine"
  1. docker-compose up redis
  2. ctrl-c to stop container
  3. yes | docker-compose rm redis

Describe the results you received:

(base) ➜ yes | docker-compose rm redis
? Going to remove compose_testing-redis-1 (y/N) ^[[69;254R^[[28;49Rpanic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xf66be0]

goroutine 1 [running]:
github.com/AlecAivazis/survey/v2/terminal.(*RuneReader).ReadLineWithDefault.func2(...)
        github.com/AlecAivazis/survey/[email protected]/terminal/runereader.go:65
github.com/AlecAivazis/survey/v2/terminal.(*RuneReader).ReadLineWithDefault(0xc0003d0d80, 0x12a000?, {0x1cda3b0, 0x0, 0x0}, {0x0?, 0x280?, 0x40d4a5?})
        github.com/AlecAivazis/survey/[email protected]/terminal/runereader.go:328 +0x880
github.com/AlecAivazis/survey/v2/terminal.(*RuneReader).ReadLine(...)
        github.com/AlecAivazis/survey/[email protected]/terminal/runereader.go:37
github.com/AlecAivazis/survey/v2.(*Confirm).getBool(0xc00078b130, 0x0, 0xc000176b48)
        github.com/AlecAivazis/survey/[email protected]/confirm.go:59 +0x186
github.com/AlecAivazis/survey/v2.(*Confirm).Prompt(0xc00078b130, 0xc000176b48)
        github.com/AlecAivazis/survey/[email protected]/confirm.go:136 +0xf6
github.com/AlecAivazis/survey/v2.Ask({0xc0008bf4a0, 0x1, 0xc0008bf488?}, {0x10326a0?, 0xc00048dbe0}, {0xc0008bf498, 0x1, 0xc0008bf4e0?})
        github.com/AlecAivazis/survey/[email protected]/survey.go:334 +0x38c
github.com/AlecAivazis/survey/v2.AskOne(...)
        github.com/AlecAivazis/survey/[email protected]/survey.go:251
github.com/docker/compose/v2/pkg/prompt.User.Confirm({}, {0xc000494900, 0x27}, 0x0)
        github.com/docker/compose/v2/pkg/prompt/prompt.go:65 +0x125
github.com/docker/compose/v2/pkg/compose.(*composeService).Remove(0xc0005bc1b0, {0x1477ab0, 0xc0005be180}, {0xc0001dac50?, 0x0?}, {0x0, 0x0, 0x0, {0xc00041efc0, 0x1, ...}})
        github.com/docker/compose/v2/pkg/compose/remove.go:60 +0x289
github.com/docker/compose/v2/pkg/api.(*ServiceProxy).Remove(0x4718a0?, {0x1477ab0?, 0xc0005be180?}, {0xc0001dac50?, 0xc000000002?}, {0x0, 0x0, 0x0, {0xc00041efc0, 0x1, ...}})
        github.com/docker/compose/v2/pkg/api/proxy.go:245 +0x86
github.com/docker/compose/v2/cmd/compose.runRemove({0x1477ab0, 0xc0005be180}, {0x1481b18, 0xc000496380}, {0xc0003d0000?, 0xf0?, 0xc3?, 0x0?}, {0xc00041efc0, 0x1, ...})
        github.com/docker/compose/v2/cmd/compose/remove.go:76 +0x13c
github.com/docker/compose/v2/cmd/compose.removeCommand.func1({0x1477ab0?, 0xc0005be180?}, {0xc00041efc0?, 0xc0000021a0?, 0xfaf45a?})
        github.com/docker/compose/v2/cmd/compose/remove.go:47 +0x5d
github.com/docker/compose/v2/cmd/compose.Adapt.func1({0x1477ab0?, 0xc0005be180?}, 0x2?, {0xc00041efc0?, 0x1?, 0x0?})
        github.com/docker/compose/v2/cmd/compose/compose.go:89 +0x36
github.com/docker/compose/v2/cmd/compose.AdaptCmd.func1(0xc0005c8f00, {0xc00041efc0, 0x1, 0x1})
        github.com/docker/compose/v2/cmd/compose/compose.go:68 +0x21c
github.com/spf13/cobra.(*Command).execute(0xc0005c8f00, {0xc0005c6b30, 0x1, 0x1})
        github.com/spf13/[email protected]/command.go:872 +0x694
github.com/spf13/cobra.(*Command).ExecuteC(0xc00016d180)
        github.com/spf13/[email protected]/command.go:990 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:918
github.com/docker/cli/cli-plugins/plugin.RunPlugin(0xc00031c100?, 0xc0002e6c80, {{0x1281f98, 0x5}, {0x128993f, 0xb}, {0x1465598, 0x6}, {0x0, 0x0}, ...})
        github.com/docker/[email protected]+incompatible/cli-plugins/plugin/plugin.go:51 +0x130
github.com/docker/cli/cli-plugins/plugin.Run(0x1319430, {{0x1281f98, 0x5}, {0x128993f, 0xb}, {0x1465598, 0x6}, {0x0, 0x0}, {0x0, ...}, ...})
        github.com/docker/[email protected]+incompatible/cli-plugins/plugin/plugin.go:64 +0xee
main.pluginMain()
        github.com/docker/compose/v2/cmd/main.go:36 +0xdf
main.main()
        github.com/docker/compose/v2/cmd/main.go:69 +0x1aa

Describe the results you expected: No panic

Additional information you deem important (e.g. issue happens only occasionally): This happens with container images other than redis. It was just the easiest example I could provide.

Using echo y | docker-compose rm redis doesn't panic but returns EOF

(base) ➜  echo y | docker-compose rm redis
? Going to remove compose_testing-redis-1 (y/N) EOF
^[[69;254R^[[43;49R%

This issue does not happen with

(base) ➜  docker-compose1 version
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

Output of docker compose version:

Docker Compose version v2.9.0

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 552
 Server Version: 20.10.17
 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: 1
 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: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 0197261a30bf81f1ee8e6a4dd2dea0ef95d67ccb
 runc version: v1.1.3-0-g6724737
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.4.0-122-generic
 Operating System: Linux Mint 20.3
 OSType: linux
 Architecture: x86_64
 CPUs: 40
 Total Memory: 125.8GiB
 Name: workdesktop
 ID: KUZO:FSYB:ELUN:FRE3:WWM7:2FAX:Q4LZ:56WB:IJMP:AQFX:7S7K:QFWJ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: user
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details:

(base) ➜  uname -a
Linux workdesktop 5.4.0-122-generic #138-Ubuntu SMP Wed Jun 22 15:00:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

jgeiger-trane avatar Aug 10 '22 17:08 jgeiger-trane