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

cmd/compile: nil pointer panic when building delve in Docker on Windows #41257

Open
codinggg opened this issue Sep 7, 2020 · 8 comments
Open

cmd/compile: nil pointer panic when building delve in Docker on Windows #41257

codinggg opened this issue Sep 7, 2020 · 8 comments
Assignees

Comments

@codinggg
Copy link

@codinggg codinggg commented Sep 7, 2020

  1. What version of Delve are you using (dlv version)?

1.5.0

  1. What version of Go are you using? (go version)?

go1.15.1 linux/amd64

  1. What operating system and processor architecture are you using?

I use windows system with open hyper-v mode, And installed virtualBox runing ubuntu system, and ubuntu run docker.

  1. What did you do?

I want to use delve to debug the golang program in the docker on the virtual machine ubuntu installed on virtualBox(a bit complicated) , but the installation of delve fails.

  1. What did you expect to see?

install success ;_)

  1. What did you see instead?
alex@alex-VirtualBox:~/docker/build-env/golang-debug$ docker run --rm -it golang-debug
root@dcf62d8a9905:/go# go get github.com/go-delve/delve/cmd/dlv
go: downloading github.com/go-delve/delve v1.5.0
go: found github.com/go-delve/delve/cmd/dlv in github.com/go-delve/delve v1.5.0
go: downloading github.com/spf13/cobra v0.0.0-20170417170307-b6cb39589372
go: downloading github.com/sirupsen/logrus v1.6.0
go: downloading github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b
go: downloading go.starlark.net v0.0.0-20190702223751-32f345186213
go: downloading gopkg.in/yaml.v2 v2.2.1
go: downloading golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb
go: downloading github.com/cosiner/argv v0.1.0
go: downloading golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4
go: downloading github.com/spf13/pflag v0.0.0-20170417173400-9e4c21054fa1
go: downloading github.com/konsorten/go-windows-terminal-sequences v1.0.3
go: downloading github.com/hashicorp/golang-lru v0.5.4
go: downloading github.com/cpuguy83/go-md2man v1.0.10
go: downloading github.com/mattn/go-isatty v0.0.3
go: downloading github.com/google/go-dap v0.2.0
go: downloading github.com/inconshreveable/mousetrap v1.0.0
go: downloading github.com/mattn/go-colorable v0.0.0-20170327083344-ded68f7a9561
go: downloading github.com/russross/blackfriday v1.5.2
# github.com/go-delve/delve/pkg/dwarf/util
unexpected fault address 0x0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x50ed98]

goroutine 1 [running]:
runtime.throw(0xc422cd, 0x5)
        /usr/local/go/src/runtime/panic.go:1116 +0x72 fp=0xc0003794c0 sp=0xc000379490 pc=0x436a52
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:727 +0x405 fp=0xc0003794f0 sp=0xc0003794c0 pc=0x44cf45
cmd/internal/obj.(*Link).NumberSyms.func3(0x1d0004000000b8)
        /usr/local/go/src/cmd/internal/obj/sym.go:211 +0x38 fp=0xc000379570 sp=0xc0003794f0 pc=0x50ed98
cmd/internal/obj.(*Link).traverseSyms.func1(0xc000550680, 0x1d0004000000b8)
        /usr/local/go/src/cmd/internal/obj/sym.go:312 +0x2f fp=0xc000379588 sp=0xc000379570 pc=0x50f0ef
cmd/internal/obj.(*Link).traverseFuncAux(0xc0000f44e0, 0x6, 0xc000550600, 0xc0003796c8)
        /usr/local/go/src/cmd/internal/obj/sym.go:356 +0x256 fp=0xc000379660 sp=0xc000379588 pc=0x509556
cmd/internal/obj.(*Link).traverseSyms(0xc0000f44e0, 0x6, 0xc0003797d8)
        /usr/local/go/src/cmd/internal/obj/sym.go:314 +0x1ee fp=0xc000379760 sp=0xc000379660 pc=0x50916e
cmd/internal/obj.(*Link).NumberSyms(0xc0000f44e0, 0xc000379a00)
        /usr/local/go/src/cmd/internal/obj/sym.go:210 +0x1bf fp=0xc000379838 sp=0xc000379760 pc=0x508d1f
cmd/compile/internal/gc.Main(0xc6e518)
        /usr/local/go/src/cmd/compile/internal/gc/main.go:793 +0x3785 fp=0xc000379f10 sp=0xc000379838 pc=0xa5f1e5
main.main()
        /usr/local/go/src/cmd/compile/main.go:52 +0xb1 fp=0xc000379f88 sp=0xc000379f10 pc=0xba6471
runtime.main()
        /usr/local/go/src/runtime/proc.go:204 +0x209 fp=0xc000379fe0 sp=0xc000379f88 pc=0x439249
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1374 +0x1 fp=0xc000379fe8 sp=0xc000379fe0 pc=0x46cc21
# golang.org/x/arch/x86/x86asm
panic: runtime error: index out of range [-1820413807]

goroutine 13 [running]:
cmd/compile/internal/gc.genssa.func1(0x937eb091ffd8f008, 0xc001669071)
        /usr/local/go/src/cmd/compile/internal/gc/ssa.go:6191 +0xd5
cmd/compile/internal/ssa.(*FuncDebug).PutLocationList(0xc0018ba850, 0xc001669040, 0x99, 0x12c, 0xc0002f8340, 0xc000b4da80, 0xc000b4d880)
        /usr/local/go/src/cmd/compile/internal/ssa/debug.go:1088 +0x122
cmd/compile/internal/gc.createComplexVar.func1(0xd4d240, 0xc000b4da80, 0xd4d240, 0xc000b4d880)
        /usr/local/go/src/cmd/compile/internal/gc/pgen.go:761 +0x87
cmd/internal/dwarf.putvar(0xd58a80, 0xc0002f8340, 0xc00056fcd0, 0xc0018ba9a0, 0xd4d240, 0x0, 0x3, 0xffffffffffffffff, 0xc0018c8540, 0x0, ...)
        /usr/local/go/src/cmd/internal/dwarf/dwarf.go:1592 +0x2c2
cmd/internal/dwarf.putscope(0xd58a80, 0xc0002f8340, 0xc00056fcd0, 0xc000339a40, 0x1, 0x1, 0x0, 0x3, 0xc0018c8540, 0x0, ...)
        /usr/local/go/src/cmd/internal/dwarf/dwarf.go:1425 +0x10d
cmd/internal/dwarf.putPrunedScopes(0xd58a80, 0xc0002f8340, 0xc00056fcd0, 0x3, 0x3, 0xc)
        /usr/local/go/src/cmd/internal/dwarf/dwarf.go:1170 +0x45d
cmd/internal/dwarf.PutDefaultFunc(0xd58a80, 0xc0002f8340, 0xc00056fcd0, 0xc00038bce0, 0xc0003399c0)
        /usr/local/go/src/cmd/internal/dwarf/dwarf.go:1397 +0x3b9
cmd/internal/obj.(*Link).populateDWARF(0xc0002f8340, 0xc3d720, 0xc00038bce0, 0xc000b4d880, 0x7fff7b00fa6c, 0x1c)
        /usr/local/go/src/cmd/internal/obj/objfile.go:646 +0x58c
cmd/internal/obj.Flushplist(0xc0002f8340, 0xc00056fea8, 0xc00067d4e0, 0x7fff7b00fa6c, 0x1c)
        /usr/local/go/src/cmd/internal/obj/plist.go:113 +0x7fa
cmd/compile/internal/gc.(*Progs).Flush(0xc000efc300)
        /usr/local/go/src/cmd/compile/internal/gc/gsubr.go:98 +0xbd
cmd/compile/internal/gc.compileSSA(0xc00038bce0, 0x1)
        /usr/local/go/src/cmd/compile/internal/gc/pgen.go:342 +0x68e
cmd/compile/internal/gc.compileFunctions.func2(0xc00126e480, 0xc000ee0390, 0x1)
        /usr/local/go/src/cmd/compile/internal/gc/pgen.go:382 +0x4d
created by cmd/compile/internal/gc.compileFunctions
        /usr/local/go/src/cmd/compile/internal/gc/pgen.go:380 +0x129
# github.com/sirupsen/logrus
pkg/mod/github.com/sirupsen/logrus@v1.6.0/logger.go:133:2: internal compiler error: '(*Logger).WithContext': schedule does not include all values in block b4

Please file a bug report including a short program that triggers the error.
https://golang.org/issue/new
root@dcf62d8a9905:/go#

By the way, I tried debug golang program with delve on above system environment was success. Util I open hyper-v,install docker in windows system.

@ALTree ALTree changed the title build delve failed in docker cmd/go: build delve failed in docker Sep 8, 2020
@jayconrod jayconrod changed the title cmd/go: build delve failed in docker cmd/compile: nil pointer panic when building delve in Docker on Windows Sep 21, 2020
@randall77
Copy link
Contributor

@randall77 randall77 commented Sep 25, 2020

runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:727 +0x405 fp=0xc0003794f0 sp=0xc0003794c0 pc=0x44cf45
cmd/internal/obj.(*Link).NumberSyms.func3(0x1d0004000000b8)
        /usr/local/go/src/cmd/internal/obj/sym.go:211 +0x38 fp=0xc000379570 sp=0xc0003794f0 pc=0x50ed98
cmd/internal/obj.(*Link).traverseSyms.func1(0xc000550680, 0x1d0004000000b8)

That address 0x1d0004000000b8 looks bad. Not sure why the segv address is 0 (maybe because the address is outside 48-bit?).
Not sure where the bad address comes from.

This seems to be at the intersection of DWARF and the new linker (and/or the new object file format). @thanm

@thanm
Copy link
Member

@thanm thanm commented Sep 25, 2020

Thanks for the report. I'll take a look.

Could you please attach "go env" output from the virtualbox environment?

@thanm thanm self-assigned this Sep 25, 2020
@codinggg
Copy link
Author

@codinggg codinggg commented Sep 26, 2020

Hello, I build delve on docker vm.

root@cd43bd027de1:/golib/src/github.com/go-delve/delve# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/golib/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/golib"
GOPRIVATE=""
GOPROXY="https://goproxy.io"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/golib/src/github.com/go-delve/delve/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build957973566=/tmp/go-build -gno-record-gcc-switches"

@codinggg
Copy link
Author

@codinggg codinggg commented Sep 27, 2020

It probably is virtualBox bug, It is not long ago virtualBox and hyperv conexist together, and I try the new features

@codinggg
Copy link
Author

@codinggg codinggg commented Sep 28, 2020

currently, I try make again to build delve, still has error, but I cat make install it when I try several times.

root@cd603a1977bd:/golib/src/github.com/go-delve/delve# make install
go install "-ldflags=-X main.Build=7555d1c06339e51a4f1e2d7a62dc9c44745e10b7" github.com/go-delve/delve/cmd/dlv
go: downloading github.com/sirupsen/logrus v1.6.0
go: downloading github.com/mattn/go-isatty v0.0.3
go: downloading golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae
go: downloading github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b
go: downloading gopkg.in/yaml.v2 v2.2.1
go: downloading github.com/cpuguy83/go-md2man v1.0.10
go: downloading golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4
go: downloading github.com/cosiner/argv v0.1.0
go: downloading github.com/google/go-dap v0.2.0
go: downloading github.com/russross/blackfriday v1.5.2
go: downloading github.com/hashicorp/golang-lru v0.5.4
go: downloading go.starlark.net v0.0.0-20200821142938-949cc6f4b097
# github.com/go-delve/delve/pkg/proc
unexpected fault address 0x0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x50ed98]

goroutine 1 [running]:
runtime.throw(0xc422cd, 0x5)
        /usr/local/go/src/runtime/panic.go:1116 +0x72 fp=0xc0026074c0 sp=0xc002607490 pc=0x436a52
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:727 +0x405 fp=0xc0026074f0 sp=0xc0026074c0 pc=0x44cf45
cmd/internal/obj.(*Link).NumberSyms.func3(0x18000000000000)
        /usr/local/go/src/cmd/internal/obj/sym.go:211 +0x38 fp=0xc002607570 sp=0xc0026074f0 pc=0x50ed98
cmd/internal/obj.(*Link).traverseSyms.func1(0xc0020c6780, 0x18000000000000)
        /usr/local/go/src/cmd/internal/obj/sym.go:312 +0x2f fp=0xc002607588 sp=0xc002607570 pc=0x50f0ef
cmd/internal/obj.(*Link).traverseFuncAux(0xc0000f7ba0, 0x6, 0xc001cf2380, 0xc0026076c8)
        /usr/local/go/src/cmd/internal/obj/sym.go:356 +0x256 fp=0xc002607660 sp=0xc002607588 pc=0x509556
cmd/internal/obj.(*Link).traverseSyms(0xc0000f7ba0, 0x6, 0xc0026077d8)
        /usr/local/go/src/cmd/internal/obj/sym.go:314 +0x1ee fp=0xc002607760 sp=0xc002607660 pc=0x50916e
cmd/internal/obj.(*Link).NumberSyms(0xc0000f7ba0, 0xc0044dba00)
        /usr/local/go/src/cmd/internal/obj/sym.go:210 +0x1bf fp=0xc002607838 sp=0xc002607760 pc=0x508d1f
cmd/compile/internal/gc.Main(0xc6e518)
        /usr/local/go/src/cmd/compile/internal/gc/main.go:793 +0x3785 fp=0xc002607f10 sp=0xc002607838 pc=0xa5f1e5
main.main()
        /usr/local/go/src/cmd/compile/main.go:52 +0xb1 fp=0xc002607f88 sp=0xc002607f10 pc=0xba6471
runtime.main()
        /usr/local/go/src/runtime/proc.go:204 +0x209 fp=0xc002607fe0 sp=0xc002607f88 pc=0x439249
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1374 +0x1 fp=0xc002607fe8 sp=0xc002607fe0 pc=0x46cc21
exit status 1
make: *** [Makefile:10: install] Error 1
root@cd603a1977bd:/golib/src/github.com/go-delve/delve# make install
go install "-ldflags=-X main.Build=7555d1c06339e51a4f1e2d7a62dc9c44745e10b7" github.com/go-delve/delve/cmd/dlv
# github.com/go-delve/delve/pkg/proc
pkg/proc/target_exec.go:932:9: internal compiler error: 'findCallInstrForRet': two stores live simultaneously: v58 and v1

Please file a bug report including a short program that triggers the error.
https://golang.org/issue/new
exit status 1
make: *** [Makefile:10: install] Error 1
root@cd603a1977bd:/golib/src/github.com/go-delve/delve# make
go: downloading github.com/creack/pty v1.1.9
go: downloading golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f
# github.com/go-delve/delve/pkg/proc
pkg/proc/target_exec.go:253:9: internal compiler error: 'disassembleCurrentInstruction': trying to free an already freed value

Please file a bug report including a short program that triggers the error.
https://golang.org/issue/new
make: *** [Makefile:19: vet] Error 2
root@cd603a1977bd:/golib/src/github.com/go-delve/delve# make install
go install "-ldflags=-X main.Build=7555d1c06339e51a4f1e2d7a62dc9c44745e10b7" github.com/go-delve/delve/cmd/dlv
# github.com/go-delve/delve/pkg/terminal
unexpected fault address 0x0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x50ed98]

goroutine 1 [running]:
runtime.throw(0xc422cd, 0x5)
        /usr/local/go/src/runtime/panic.go:1116 +0x72 fp=0xc00236f4c0 sp=0xc00236f490 pc=0x436a52
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:727 +0x405 fp=0xc00236f4f0 sp=0xc00236f4c0 pc=0x44cf45
cmd/internal/obj.(*Link).NumberSyms.func3(0x18000000000000)
        /usr/local/go/src/cmd/internal/obj/sym.go:211 +0x38 fp=0xc00236f570 sp=0xc00236f4f0 pc=0x50ed98
cmd/internal/obj.(*Link).traverseSyms.func1(0xc000684c00, 0x18000000000000)
        /usr/local/go/src/cmd/internal/obj/sym.go:312 +0x2f fp=0xc00236f588 sp=0xc00236f570 pc=0x50f0ef
cmd/internal/obj.(*Link).traverseFuncAux(0xc00037a680, 0x6, 0xc000684b00, 0xc00236f6c8)
        /usr/local/go/src/cmd/internal/obj/sym.go:356 +0x256 fp=0xc00236f660 sp=0xc00236f588 pc=0x509556
cmd/internal/obj.(*Link).traverseSyms(0xc00037a680, 0x6, 0xc00236f7d8)
        /usr/local/go/src/cmd/internal/obj/sym.go:314 +0x1ee fp=0xc00236f760 sp=0xc00236f660 pc=0x50916e
cmd/internal/obj.(*Link).NumberSyms(0xc00037a680, 0xc001e3ba00)
        /usr/local/go/src/cmd/internal/obj/sym.go:210 +0x1bf fp=0xc00236f838 sp=0xc00236f760 pc=0x508d1f
cmd/compile/internal/gc.Main(0xc6e518)
        /usr/local/go/src/cmd/compile/internal/gc/main.go:793 +0x3785 fp=0xc00236ff10 sp=0xc00236f838 pc=0xa5f1e5
main.main()
        /usr/local/go/src/cmd/compile/main.go:52 +0xb1 fp=0xc00236ff88 sp=0xc00236ff10 pc=0xba6471
runtime.main()
        /usr/local/go/src/runtime/proc.go:204 +0x209 fp=0xc00236ffe0 sp=0xc00236ff88 pc=0x439249
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1374 +0x1 fp=0xc00236ffe8 sp=0xc00236ffe0 pc=0x46cc21
exit status 1
make: *** [Makefile:10: install] Error 1
root@cd603a1977bd:/golib/src/github.com/go-delve/delve# make install
go install "-ldflags=-X main.Build=7555d1c06339e51a4f1e2d7a62dc9c44745e10b7" github.com/go-delve/delve/cmd/dlv
root@cd603a1977bd:/golib/src/github.com/go-delve/delve#
root@cd603a1977bd:/golib/src/github.com/go-delve/delve#
root@cd603a1977bd:/golib/src/github.com/go-delve/delve# cd ../../../
root@cd603a1977bd:/golib/src# cd ../bin/
root@cd603a1977bd:/golib/bin# ls
dlv

@davecheney
Copy link
Contributor

@davecheney davecheney commented Sep 28, 2020

@codinggg I am not able to reproduce the compiler crash on linux/amd64. Do you think this could be something to do with your local envornment? Given you are building in a virtual machine, would it be possible for you to try a different virtual configuration -- docker? github codespaces ? a linux machine from a cloud vendor? and see if you can reproduce the issue outside your workstation?

@thanm
Copy link
Member

@thanm thanm commented Sep 28, 2020

but I can make install it when I try several times

I agree with @davecheney -- likely that the problem is something to do with the environment. Just to confirm, you are saying that the build eventually succeeds if you just try multiple times? That seems very odd.

@codinggg
Copy link
Author

@codinggg codinggg commented Sep 29, 2020

@davecheney Hello. Yes, I think it is on my local environment. It's success before when I open hyper-v and installed wsl2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants