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: Seg fault while compiling #18392
Comments
Does this happen repeatabily on multiple machines?
…On Wed, 21 Dec 2016, 08:35 Alex Robinson ***@***.***> wrote:
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version go1.7.3 darwin/amd64
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/alex/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7.3/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7.3/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments
-fmessage-length=0
-fdebug-prefix-map=/var/folders/0y/zlxqfzj16sgfrxt7p13jqxhw0000gn/T/go-build613475394=/tmp/go-build
-gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
What did you do?
I realize there are a lot of layers to un-peel here, so feel free to close
if it's too much effort to reproduce.
I made some modifications to CockroachDB
<https://github.com/cockroachdb/cockroach>'s codebase and tried building
it with make build (which just wraps go build). With a few particular
modifications, it reliably triggers a segmentation fault in the compiler.
The line of code that triggers it is this function declaration in an
interface definition
<https://github.com/a-robinson/cockroach/blob/compiler-segfault/pkg/migrations/migrations.go#L87>,
referring to the non-existent db.Txn. If I switch it to refer to the
valid client.Txn type, then there's no segfault.
I have the state saved in a branch on my fork, so reproducing should look
something like:
go get github.com/a-robinson/cockroach
cd to directory
git fetch https://github.com/a-robinson/cockroach.git
git checkout compiler-segfault
make build
What did you expect to see?
Compiler errors from my bad code.
What did you see instead?
~/go/src/github.com/cockroachdb/cockroach/pkg 0 $ make buildGOPATH set to /Users/alex/go/Users/alex/go/bin added to PATHgo build -i -o cockroach -vgithub.com/cockroachdb/cockroach/pkg/configgithub.com/cockroachdb/cockroach/pkg/gossipgithub.com/cockroachdb/cockroach/pkg/sql/sqlbasegithub.com/cockroachdb/cockroach/pkg/storage/enginegithub.com/cockroachdb/cockroach/pkg/kvgithub.com/cockroachdb/cockroach/pkg/server/serverpbgithub.com/cockroachdb/cockroach/pkg/sql/distsqlplangithub.com/cockroachdb/cockroach/pkg/sql/distsqlrungithub.com/cockroachdb/cockroach/pkg/storagegithub.com/cockroachdb/cockroach/pkg/sqlgithub.com/cockroachdb/cockroach/pkg/tsgithub.com/cockroachdb/cockroach/pkg/migrationsgithub.com/cockroachdb/cockroach/pkg/sql/pgwire
# github.com/cockroachdb/cockroach/pkg/migrationspanic: runtime error: invalid memory address or nil pointer dereference[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x247f07]
goroutine 1 [running]:panic(0x4b76e0, 0xc420010150) /usr/local/Cellar/go/1.7.3/libexec/src/runtime/panic.go:500 +0x1a1cmd/compile/internal/gc.typecheck1(0xc423658870, 0x6, 0xc423671120) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:864 +0x6ff7cmd/compile/internal/gc.typecheck(0xc423658870, 0x6, 0xc423698318) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:188 +0x654cmd/compile/internal/gc.typecheck1(0xc423658900, 0x4, 0x38) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:476 +0x7e45cmd/compile/internal/gc.typecheck(0xc423658900, 0x4, 0x8) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:188 +0x654cmd/compile/internal/gc.structfield(0xc423658a20, 0x1) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/dcl.go:750 +0x2cacmd/compile/internal/gc.tofunargs(0xc4236304a0, 0x1, 0x1, 0x2, 0xc423685590) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/dcl.go:845 +0xc3cmd/compile/internal/gc.functype0(0xc4236854f0, 0x0, 0xc4236304a0, 0x1, 0x1, 0xc4236304a8, 0x1, 0x1) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/dcl.go:1039 +0x1a5cmd/compile/internal/gc.functype(0x0, 0xc4236304a0, 0x1, 0x1, 0xc4236304a8, 0x1, 0x1, 0xc423684c80) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/dcl.go:1024 +0x89cmd/compile/internal/gc.typecheck1(0xc423658bd0, 0x4, 0x38) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:466 +0xc8c8cmd/compile/internal/gc.typecheck(0xc423658bd0, 0x4, 0xc4203c8ea0) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:188 +0x654cmd/compile/internal/gc.structfield(0xc423658e10, 0xc42365eb40) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/dcl.go:750 +0x2cacmd/compile/internal/gc.tofunargs(0xc42363a930, 0x2, 0x2, 0x2, 0xc423685450) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/dcl.go:845 +0xc3cmd/compile/internal/gc.functype0(0xc4236853b0, 0xc4236587e0, 0xc42363a930, 0x2, 0x2, 0xc4236304b0, 0x1, 0x1) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/dcl.go:1039 +0x1a5cmd/compile/internal/gc.functype(0xc4236587e0, 0xc42363a930, 0x2, 0x2, 0xc4236304b0, 0x1, 0x1, 0xc423685220) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/dcl.go:1024 +0x89cmd/compile/internal/gc.typecheck1(0xc423658fc0, 0x4, 0xc423658510) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:466 +0xc8c8cmd/compile/internal/gc.typecheck(0xc423658fc0, 0x4, 0xc423658510) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:188 +0x654cmd/compile/internal/gc.domethod(0xc423659050) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:3422 +0x4acmd/compile/internal/gc.typecheckdeftype(0xc42364a5a0) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:3541 +0x166cmd/compile/internal/gc.typecheckdef(0xc42364a5a0, 0xc4227bbb50) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:3711 +0x770cmd/compile/internal/gc.typecheck1(0xc42364a5a0, 0x4, 0x1) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:266 +0xd3e0cmd/compile/internal/gc.typecheck(0xc42364a5a0, 0x4, 0x10000000003b680) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:188 +0x654cmd/compile/internal/gc.typecheck1(0xc42364acf0, 0x1, 0xc4227bdb88) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:2086 +0x637ecmd/compile/internal/gc.typecheck(0xc42364acf0, 0x1, 0x0) /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/typecheck.go:188 +0x654cmd/compile/internal/gc.Main() /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/gc/main.go:367 +0x15efcmd/compile/internal/amd64.Main() /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/internal/amd64/galign.go:93 +0x2famain.main() /usr/local/Cellar/go/1.7.3/libexec/src/cmd/compile/main.go:33 +0x2a3make[1]: *** [install] Error 2make: *** [build] Error 2
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#18392>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA-o67EJCuocMvruLaUYLMJrakH8hks5rKEoLgaJpZM4LSUxx>
.
|
Yeah, it also triggers on a linux box:
|
Thanks for confirming.
…On Wed, 21 Dec 2016, 08:44 Alex Robinson ***@***.***> wrote:
Yeah, it also triggers on a linux box:
$ go version
go version go1.7.3 linux/amd64
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/alex/go"
GORACE=""
GOROOT="/home/alex/goroot"
GOTOOLDIR="/home/alex/goroot/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build964405033=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
# github.com/cockroachdb/cockroach/pkg/migrations
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x647a17]
goroutine 1 [running]:
panic(0x8b82c0, 0xc42000e130)
/home/alex/goroot/src/runtime/panic.go:500 +0x1a1
cmd/compile/internal/gc.typecheck1(0xc42371c1b0, 0x6, 0xc423731080)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:864 +0x6ff7
cmd/compile/internal/gc.typecheck(0xc42371c1b0, 0x6, 0xc42375c318)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:188 +0x654
cmd/compile/internal/gc.typecheck1(0xc42371c240, 0x4, 0x38)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:476 +0x7e45
cmd/compile/internal/gc.typecheck(0xc42371c240, 0x4, 0x8)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:188 +0x654
cmd/compile/internal/gc.structfield(0xc42371c360, 0x1)
/home/alex/goroot/src/cmd/compile/internal/gc/dcl.go:750 +0x2ca
cmd/compile/internal/gc.tofunargs(0xc4236fa398, 0x1, 0x1, 0x2, 0xc423747bd0)
/home/alex/goroot/src/cmd/compile/internal/gc/dcl.go:845 +0xc3
cmd/compile/internal/gc.functype0(0xc423747b30, 0x0, 0xc4236fa398, 0x1, 0x1, 0xc4236fa3a0, 0x1, 0x1)
/home/alex/goroot/src/cmd/compile/internal/gc/dcl.go:1039 +0x1a5
cmd/compile/internal/gc.functype(0x0, 0xc4236fa398, 0x1, 0x1, 0xc4236fa3a0, 0x1, 0x1, 0xc4237472c0)
/home/alex/goroot/src/cmd/compile/internal/gc/dcl.go:1024 +0x89
cmd/compile/internal/gc.typecheck1(0xc42371c510, 0x4, 0x38)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:466 +0xc8c8
cmd/compile/internal/gc.typecheck(0xc42371c510, 0x4, 0xc4200b6d80)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:188 +0x654
cmd/compile/internal/gc.structfield(0xc42371c750, 0xc423736880)
/home/alex/goroot/src/cmd/compile/internal/gc/dcl.go:750 +0x2ca
cmd/compile/internal/gc.tofunargs(0xc423700720, 0x2, 0x2, 0x2, 0xc423747a90)
/home/alex/goroot/src/cmd/compile/internal/gc/dcl.go:845 +0xc3
cmd/compile/internal/gc.functype0(0xc4237479f0, 0xc42371c120, 0xc423700720, 0x2, 0x2, 0xc4236fa3a8, 0x1, 0x1)
/home/alex/goroot/src/cmd/compile/internal/gc/dcl.go:1039 +0x1a5
cmd/compile/internal/gc.functype(0xc42371c120, 0xc423700720, 0x2, 0x2, 0xc4236fa3a8, 0x1, 0x1, 0xc423747860)
/home/alex/goroot/src/cmd/compile/internal/gc/dcl.go:1024 +0x89
cmd/compile/internal/gc.typecheck1(0xc42371c900, 0x4, 0xc423717dd0)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:466 +0xc8c8
cmd/compile/internal/gc.typecheck(0xc42371c900, 0x4, 0xc423717dd0)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:188 +0x654
cmd/compile/internal/gc.domethod(0xc42371c990)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:3422 +0x4a
cmd/compile/internal/gc.typecheckdeftype(0xc42370be60)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:3541 +0x166
cmd/compile/internal/gc.typecheckdef(0xc42370be60, 0xc422891b50)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:3711 +0x770
cmd/compile/internal/gc.typecheck1(0xc42370be60, 0x4, 0x1)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:266 +0xd3e0
cmd/compile/internal/gc.typecheck(0xc42370be60, 0x4, 0x10000000043ad00)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:188 +0x654
cmd/compile/internal/gc.typecheck1(0xc423712630, 0x1, 0xc422893b88)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:2086 +0x637e
cmd/compile/internal/gc.typecheck(0xc423712630, 0x1, 0x0)
/home/alex/goroot/src/cmd/compile/internal/gc/typecheck.go:188 +0x654
cmd/compile/internal/gc.Main()
/home/alex/goroot/src/cmd/compile/internal/gc/main.go:367 +0x15ef
cmd/compile/internal/amd64.Main()
/home/alex/goroot/src/cmd/compile/internal/amd64/galign.go:93 +0x2fa
main.main()
/home/alex/goroot/src/cmd/compile/main.go:33 +0x2a3
Makefile:89: recipe for target 'install' failed
make: *** [install] Error 2
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#18392 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA068-1c-3YY0tIt4NHmjJbm5g8Lqks5rKEwqgaJpZM4LSUxx>
.
|
Is this still an issue with Go 1.8? Could you try it?
|
@rakyll yup:
|
/cc @ianlancetaylor @quentinmit @bradfitz to decide if this fix will be in Go 1.8 vs Go 1.9. |
Well, it's not a regression from the last release (since Go 1.7 is also broken), so technically it's not super urgent, but maybe the fix is trivial. @mdempsky, @griesemer? |
Ping @mdempsky, @griesemer. Or @josharian, @randall77? |
Here is an isolated repro https://play.golang.org/p/9NkQNP6TMm package main
type A interface {
Fn(*A.Fn)
}
func main() {
} |
From my quick investigation and reading of the code in cmd/compile/internal/gc/typecheck.go, seems n.Right is nil and n.Type is TINTERMETH hence we are dereferencing a nil right hand side node to try to get it's symbol |
CL https://golang.org/cl/34817 mentions this issue. |
A bit irrelevant
isn't the compiling error message some misleading? |
Fix was indeed trivial. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.7.3 darwin/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/alex/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7.3/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7.3/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0y/zlxqfzj16sgfrxt7p13jqxhw0000gn/T/go-build613475394=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
What did you do?
I realize there are a lot of layers to un-peel here, so feel free to close if it's too much effort to reproduce.
I made some modifications to CockroachDB's codebase and tried building it with
make build
(which just wrapsgo build
). With a few particular modifications, it reliably triggers a segmentation fault in the compiler. The line of code that triggers it is this function declaration in an interface definition, referring to the non-existentdb.Txn
. If I switch it to refer to the validclient.Txn
type, then there's no segfault.I have the state saved in a branch on my fork, so reproducing should look something like:
go get github.com/a-robinson/cockroach
cd to directory
git fetch https://github.com/a-robinson/cockroach.git
git checkout compiler-segfault
make build
What did you expect to see?
Compiler errors from my bad code.
What did you see instead?
The text was updated successfully, but these errors were encountered: