burrowers / garble

Obfuscate Go builds
BSD 3-Clause "New" or "Revised" License
3.93k stars 248 forks source link

containerd module causes an EmbeddedAliasFields panic #827

Open chkp-alonma opened 8 months ago

chkp-alonma commented 8 months ago

What version of Garble and Go are you using?

$ garble version
mvdan.cc/garble v0.11.0

Build settings:
      -buildmode exe
       -compiler gc
     CGO_ENABLED 1
          GOARCH arm64
            GOOS darwin
$ go version
go version go1.21.3 darwin/arm64

What environment are you running Garble on?

go env Output
$ go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/alonma/Library/Caches/go-build'
GOENV='/Users/alonma/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/alonma/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/alonma/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.3'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/alonma/projects/syft/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/yc/b45c2c412rb_dkjb1gd1bmbw0000gq/T/go-build1268150911=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I tried building my project with garble

What did you expect to see?

Build going through and go binary

What did you see instead?

error pointing to containerd package

build output
# github.com/containerd/containerd/remotes/docker/config
panic: EmbeddedAliasFields pointed "github.com/containerd/containerd/remotes/docker/config.HostFileConfig - hosts.go:372" to a missing type {"github.com/containerd/containerd/remotes/docker/config" "HostFileConfig"} [recovered]
    panic: EmbeddedAliasFields pointed "github.com/containerd/containerd/remotes/docker/config.HostFileConfig - hosts.go:372" to a missing type {"github.com/containerd/containerd/remotes/docker/config" "HostFileConfig"}

goroutine 1 [running]:
golang.org/x/tools/go/ast/astutil.Apply.func1()
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:48 +0xb8
panic({0x10331cac0?, 0x14000e103c0?})
    /usr/local/go/src/runtime/panic.go:914 +0x218
main.(*transformer).transformGoFile.func1(0x14000ad8310)
    ../../../../go/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:1916 +0xe9c
golang.org/x/tools/go/ast/astutil.(*application).apply(0x14000ad8300, {0x103387bd0?, 0x14000aacc00?}, {0x103272def?, 0x5?}, 0x10302d710?, {0x103387b08?, 0x14000aab780?})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:199 +0x180
golang.org/x/tools/go/ast/astutil.(*application).apply(0x14000ad8300, {0x1033884e0?, 0x14000aa13e0?}, {0x103272ecb?, 0x10?}, 0x14000e80000?, {0x103387bd0?, 0x14000aacc00?})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:222 +0x280
golang.org/x/tools/go/ast/astutil.(*application).applyList(0x14000ad8300, {0x1033884e0?, 0x14000aa13e0}, {0x103272ecb, 0x4})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:484 +0x7c
golang.org/x/tools/go/ast/astutil.(*application).apply(0x14000ad8300, {0x103388620?, 0x14000a95818?}, {0x1032735fd?, 0x10?}, 0x14000e80000?, {0x1033884e0?, 0x14000aa13e0?})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:227 +0x314
golang.org/x/tools/go/ast/astutil.(*application).apply(0x14000ad8300, {0x1033882b0?, 0x14000aaccc0?}, {0x103272def?, 0x14000838f18?}, 0x10302d710?, {0x103388620?, 0x14000a95818?})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:293 +0xc10
golang.org/x/tools/go/ast/astutil.(*application).apply(0x14000ad8300, {0x103388120?, 0x14000aacd00?}, {0x103272c5e?, 0x0?}, 0x0?, {0x1033882b0?, 0x14000aaccc0?})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:241 +0x47c
golang.org/x/tools/go/ast/astutil.(*application).applyList(0x14000ad8300, {0x103388120?, 0x14000aacd00}, {0x103272c5e, 0x3})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:484 +0x7c
golang.org/x/tools/go/ast/astutil.(*application).apply(0x14000ad8300, {0x103388148?, 0x14000aa1620?}, {0x103272ecb?, 0x103318da0?}, 0x0?, {0x103388120?, 0x14000aacd00?})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:338 +0x10e8
golang.org/x/tools/go/ast/astutil.(*application).applyList(0x14000ad8300, {0x103388148?, 0x14000aa1620}, {0x103272ecb, 0x4})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:484 +0x7c
golang.org/x/tools/go/ast/astutil.(*application).apply(0x14000ad8300, {0x103387b58?, 0x14000aa1650?}, {0x103272df3?, 0x140008394b8?}, 0x10302d710?, {0x103388148?, 0x14000aa1620?})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:353 +0x121c
golang.org/x/tools/go/ast/astutil.(*application).apply(0x14000ad8300, {0x103387b30?, 0x1400089e960?}, {0x103273271?, 0x14000839668?}, 0x102fbc92c?, {0x103387b58?, 0x14000aa1650?})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:429 +0x1cac
golang.org/x/tools/go/ast/astutil.(*application).applyList(0x14000ad8300, {0x103387b30?, 0x1400089e960}, {0x103273271, 0x5})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:484 +0x7c
golang.org/x/tools/go/ast/astutil.(*application).apply(0x14000ad8300, {0x103388990?, 0x14000ae49b0?}, {0x103272ec7?, 0x64?}, 0x55?, {0x103387b30?, 0x1400089e960?})
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:435 +0x1d40
golang.org/x/tools/go/ast/astutil.Apply({0x103387b30?, 0x1400089e960}, 0x14000ae4990, 0x14000ae49a0)
    ../../../../go/pkg/mod/golang.org/x/tools@v0.15.0/go/ast/astutil/rewrite.go:53 +0x110
main.(*transformer).transformGoFile(0x14000083200, 0x14000aa6200?)
    ../../../../go/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:2082 +0xf4
main.(*transformer).transformCompile(0x14000083200, {0x140000201b0?, 0x140000260b4?, 0x36?})
    ../../../../go/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:1042 +0x950
main.mainErr({0x14000020190, 0x16, 0x10358e100?})
    ../../../../go/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:457 +0x740
main.main1()
    ../../../../go/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:254 +0x21c
main.main()
    ../../../../go/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:146 +0x1c
exit status 1

mvdan commented 7 months ago

We will solve this class of bugs entirely when we can start using alias tracking in Go 1.22/1.23 per https://github.com/golang/go/issues/63223 and https://github.com/golang/go/issues/64208.

I tried giving the early support in Go 1.22 a try, but I ran into a panic (https://github.com/golang/go/issues/65778), so I think it's too early.