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: compiler crash on failing to get Right parenthesis in Go1.9 #19667

Closed
odeke-em opened this issue Mar 23, 2017 · 5 comments

Comments

Projects
None yet
4 participants
@odeke-em
Copy link
Member

commented Mar 23, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version devel +346d588 Tue Mar 21 02:47:36 2017 +0000 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN="/Users/emmanuelodeke/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/emmanuelodeke/go"
GORACE=""
GOROOT="/Users/emmanuelodeke/go/src/go.googlesource.com/go"
GOTOOLDIR="/Users/emmanuelodeke/go/src/go.googlesource.com/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/v3/7z434qpx5v3bw0wh8h2myfpw0000gn/T/go-build865238795=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

Ran the code at https://play.golang.org/p/G7ybWUZKNR or inlined below

package main

import (
	"fmt"
)

func main() {
	if err := http.ListenAndServe(
}

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

main.go:9: syntax error: unexpected }, expecting expression

as it does in Go1.8

What did you see instead?

A panic

panic: syntax.Iterate: unexpected node type <nil> [recovered]
	panic: interface conversion: interface {} is string, not syntax.localError [recovered]
	panic: interface conversion: interface {} is string, not syntax.localError

goroutine 5 [running]:
cmd/compile/internal/syntax.Parse.func1(0xc420301f30)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/syntax.go:60 +0xdb
panic(0x1669000, 0xc4202f84c0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/runtime/panic.go:489 +0x26a
cmd/compile/internal/syntax.Fprint.func1(0xc420301a88, 0xc420301a00, 0xc420301a90)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:28 +0xb0
panic(0x1652de0, 0xc42001b0d0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/runtime/panic.go:489 +0x26a
cmd/compile/internal/syntax.(*printer).printRawNode(0xc420301a00, 0x0, 0x0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:678 +0x782
cmd/compile/internal/syntax.(*printer).printNode(0xc420301a00, 0x0, 0x0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:327 +0x3f
cmd/compile/internal/syntax.(*printer).printExprList(0xc420301a00, 0xc42001afe0, 0x1, 0x1)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:746 +0x88
cmd/compile/internal/syntax.(*printer).printRawNode(0xc420301a00, 0x19ddae0, 0xc4202f83c0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:401 +0x527b
cmd/compile/internal/syntax.(*printer).printNode(0xc4202c5a00, 0x19ddae0, 0xc4202f83c0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:327 +0x3f
cmd/compile/internal/syntax.(*printer).print(0xc420301a00, 0xc420300c20, 0x1, 0x1)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:250 +0x76a
cmd/compile/internal/syntax.(*printer).printRawNode(0xc4202c5a00, 0x19dd9e0, 0xc4202f8480)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:508 +0x31a9
cmd/compile/internal/syntax.(*printer).printNode(0xc420045a00, 0x19dd9e0, 0xc4202f8480)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:327 +0x3f
cmd/compile/internal/syntax.(*printer).print(0xc420301a00, 0xc4203019f0, 0x1, 0x1)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:250 +0x76a
cmd/compile/internal/syntax.Fprint(0x19db520, 0xc4202f50a0, 0x19dd9e0, 0xc4202f8480, 0x100d600, 0x1b, 0x0, 0x0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:32 +0x13b
cmd/compile/internal/syntax.String(0x19dd9e0, 0xc4202f8480, 0xc4202f8480, 0x19dd9e0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/printer.go:40 +0x69
cmd/compile/internal/syntax.(*parser).header(0xc42002ac00, 0x23, 0x2, 0x166ec01, 0x0, 0x200019defe0, 0x10, 0x2)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/parser.go:1751 +0x30b
cmd/compile/internal/syntax.(*parser).ifStmt(0xc42002ac00, 0x0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/parser.go:1766 +0xaf
cmd/compile/internal/syntax.(*parser).stmt(0xc42002ac00, 0x0, 0x0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/parser.go:1952 +0x76a
cmd/compile/internal/syntax.(*parser).stmtList(0xc42002ac00, 0xc42001afb0, 0x1, 0x1)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/parser.go:2007 +0x81
cmd/compile/internal/syntax.(*parser).funcBody(0xc42002ac00, 0x0, 0x0, 0x0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/parser.go:1154 +0x5d
cmd/compile/internal/syntax.(*parser).funcDecl(0xc42002ac00, 0x0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/parser.go:484 +0x195
cmd/compile/internal/syntax.(*parser).file(0xc42002ac00, 0x0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/parser.go:284 +0x39c
cmd/compile/internal/syntax.Parse(0xc4200149b0, 0x19db6e0, 0xc42000c508, 0xc42001aa30, 0xc42001aa40, 0x0, 0x0, 0x0, 0x0)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/syntax/syntax.go:67 +0xe4
cmd/compile/internal/gc.parseFiles.func1(0xc4202db4c0, 0x7fff5fbfe83d, 0x57)
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/noder.go:38 +0x2f5
created by cmd/compile/internal/gc.parseFiles
	/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/noder.go:27 +0x16f
@odeke-em

This comment has been minimized.

Copy link
Member Author

commented Mar 23, 2017

@bradfitz bradfitz added this to the Go1.9 milestone Mar 23, 2017

@griesemer

This comment has been minimized.

Copy link
Contributor

commented Mar 23, 2017

Fix pending.
There's also #19663 which will make situations like this more robust down the line.

@gopherbot

This comment has been minimized.

Copy link

commented Mar 23, 2017

CL https://golang.org/cl/38458 mentions this issue.

@griesemer

This comment has been minimized.

Copy link
Contributor

commented Mar 23, 2017

This is (likely) a follow-on error that's operating with incomplete nodes, hence the crash. This fix will prevent the crash and because the follow-on error is ignored, we only see the error we expect.

Fixing #19663 will make sure that we don't get incomplete nodes even in the case of errors which down the line will make this more robust.

@gopherbot gopherbot closed this in b5e1ae4 Mar 23, 2017

@odeke-em

This comment has been minimized.

Copy link
Member Author

commented Mar 23, 2017

Thanks @griesemer for the very fast turn around!

@golang golang locked and limited conversation to collaborators Mar 23, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.