docker / buildx

Docker CLI plugin for extended build capabilities with BuildKit
Apache License 2.0
3.55k stars 481 forks source link

buildx segfault with empty newline continuation #1514

Open maths22 opened 1 year ago

maths22 commented 1 year ago

Given:

RUN echo hi \

&& echo bye

If you run a multi-arch build with `docker buildx build --platform linux/arm64,linux/amd64 --builder multi-platform-builder .` it should pass

Instead the buildkit docker container crashes with a segfault:

[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xd03890] 2023-01-12 21:54:36 2023-01-12 21:54:36 goroutine 1584 [running]: 2023-01-12 21:54:36 github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb.toDispatchState({, }, {, , }, {{0x0, 0x0}, {0xffff5c549d98, 0x40014304b0}, 0x4000f5c720, ...}) 2023-01-12 21:54:36 /src/frontend/dockerfile/dockerfile2llb/convert.go:199 +0x3830 2023-01-12 21:54:36 github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb.Dockerfile2LLB({, }, {, , }, {{0x0, 0x0}, {0xffff5c549d98, 0x40014304b0}, 0x4000f5c720, ...}) 2023-01-12 21:54:36 /src/frontend/dockerfile/dockerfile2llb/convert.go:96 +0x4c 2023-01-12 21:54:36 github.com/moby/buildkit/frontend/dockerfile/builder.Build.func5.1() 2023-01-12 21:54:36 /src/frontend/dockerfile/builder/build.go:527 +0x164 2023-01-12 21:54:36 golang.org/x/sync/errgroup.(Group).Go.func1() 2023-01-12 21:54:36 /src/vendor/golang.org/x/sync/errgroup/errgroup.go:75 +0x5c 2023-01-12 21:54:36 created by golang.org/x/sync/errgroup.(Group).Go 2023-01-12 21:54:36 /src/vendor/golang.org/x/sync/errgroup/errgroup.go:72 +0xa4


If you build for only one architecture, it builds fine.  If you delete the unnecessary blank line and make the dockerfile look like this it also builds fine:

FROM alpine

RUN echo hi \ && echo bye

crazy-max commented 1 year ago

Looks related to https://github.com/moby/buildkit/issues/3495, can you try with previous dockerfile frontend version?:

# syntax=docker/dockerfile:1.4
FROM alpine

RUN echo hi \

  && echo bye