Skip to content

[BUG] Segfault during buildx initialization if no builder available #10453

@rgeorgiev583

Description

@rgeorgiev583

Description

docker compose build crashes with a SIGSEGV and outputs the following:

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

goroutine 45 [running]:
github.com/docker/buildx/builder.(*Builder).Validate(0x55ed404b53a0?)
        github.com/docker/buildx@v0.10.4/builder/builder.go:111 +0x29
github.com/docker/buildx/builder.New({0x55ed404b53a0?, 0xc000414600}, {0x0, 0x0, 0x55ed3e1f6dc7?})
        github.com/docker/buildx@v0.10.4/builder/builder.go:101 +0x27f
github.com/docker/compose/v2/pkg/compose.(*composeService).doBuildBuildkit(0xc000302640, {0x55ed404a49e0, 0xc000606200}, 0x0?, {0x55ed3f7e0ff0, 0x4})
        github.com/docker/compose/v2/pkg/compose/build_buildkit.go:36 +0x9b
github.com/docker/compose/v2/pkg/compose.(*composeService).build.func1({0x55ed404a49e0, 0xc000606200}, {0xc00036c268, 0x4})
        github.com/docker/compose/v2/pkg/compose/build.go:97 +0x6c5
github.com/docker/compose/v2/pkg/compose.(*graphTraversal).run.func1()
        github.com/docker/compose/v2/pkg/compose/dependencies.go:127 +0x63
golang.org/x/sync/errgroup.(*Group).Go.func1()
        golang.org/x/sync@v0.1.0/errgroup/errgroup.go:75 +0x64
created by golang.org/x/sync/errgroup.(*Group).Go
        golang.org/x/sync@v0.1.0/errgroup/errgroup.go:72 +0xa5

I tried to run docker build . separately, and it seems to create the image successfully:

Sending build context to Docker daemon  4.096kB
Step 1/1 : FROM alpine
 ---> 9ed4aefc74f6
Successfully built 9ed4aefc74f6

Steps To Reproduce

I tested using a minimal example config for building of an image through Compose. You can find it in compose-build.zip. Just extract the files into a directory and run docker-compose build to reproduce the bug.
compose-build.zip

Compose Version

Docker Compose version 2.17.2

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc., 2.17.2)

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 19
 Server Version: 20.10.23-ce
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: local
 Cgroup Driver: systemd
 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 oci runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1e1ea6e986c6c86565bc33d52e34b81b3e2bc71f
 runc version: v1.1.5-0-gf19387a6bec4
 init version: 
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 6.2.9-1-default
 Operating System: openSUSE Tumbleweed
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 30.65GiB
 Name: rgeorgiev-elitebook
 ID: 6YAH:223S:VX5Z:TZHA:S55P:ICJJ:EWC2:YGV2:N3CJ:QKBC:6T34:XVEY
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions