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: internal compiler error: unexpected dot in identifier: .anon0 #25101

Closed
mhilton opened this issue Apr 26, 2018 · 3 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@mhilton
Copy link

mhilton commented Apr 26, 2018

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

go version devel +736390c2bd Thu Apr 26 07:07:18 2018 +0000 linux/amd64

Does this issue reproduce with the latest release?

No, version 1.10.1 seems fine

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mhilton/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mhilton/go"
GORACE=""
GOROOT="/home/mhilton/opt/go"
GOTMPDIR=""
GOTOOLDIR="/home/mhilton/opt/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build736391734=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. Create the following files:

==> local/a/a.go <==

package a

import "local/a/b"

var (
	x b.X
	y = x.Y
)

==> local/a/b/b.go <==

package b

type X interface {
	Y(int)
}

==> local/a/a_test.go <==

package a

var Y = &y

run go test local/a

What did you expect to see?

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4e5e2d]

goroutine 1 [running]:
local/a.init()
	/home/mhilton/go/src/local/a/a.go:7 +0x4d
FAIL	local/a	0.003s

What did you see instead?

# local/a [local/a.test]
<autogenerated>:1: internal compiler error: unexpected dot in identifier: .anon0

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
	/home/mhilton/opt/go/src/runtime/debug/stack.go:24 +0xa7
cmd/compile/internal/gc.Fatalf(0xc13281, 0x20, 0xc0003a2fb0, 0x1, 0x1)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/subr.go:182 +0x1f7
cmd/compile/internal/gc.(*exportWriter).localIdent(0xc00034acf0, 0xc00006f500, 0x0)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:1383 +0x3e1
cmd/compile/internal/gc.(*exportWriter).param(0xc00034acf0, 0xc000022480)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:723 +0x92
cmd/compile/internal/gc.(*exportWriter).paramList(0xc00034acf0, 0xc00000c0e8, 0x1, 0x1)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:717 +0x5a
cmd/compile/internal/gc.(*exportWriter).signature(0xc00034acf0, 0xc00006f560)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:707 +0x4b
cmd/compile/internal/gc.(*exportWriter).doTyp(0xc00034acf0, 0xc00006f560)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:646 +0x6f0
cmd/compile/internal/gc.(*iexporter).typOff(0xc0000a4ea0, 0xc00006f560, 0x1200000000000001)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:597 +0xab
cmd/compile/internal/gc.(*exportWriter).typ(0xc00034ac60, 0xc00006f560)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:580 +0x38
cmd/compile/internal/gc.(*exportWriter).doTyp(0xc00034ac60, 0xc00006f740)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:622 +0x731
cmd/compile/internal/gc.(*iexporter).typOff(0xc0000a4ea0, 0xc00006f740, 0x7ffcf3c1c5fc)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:597 +0xab
cmd/compile/internal/gc.(*exportWriter).typ(0xc00034abd0, 0xc00006f740)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:580 +0x38
cmd/compile/internal/gc.(*iexporter).doDecl(0xc0000a4ea0, 0xc00038e3c0)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:422 +0x2ef
cmd/compile/internal/gc.iexport(0xc00035f000)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/iexport.go:276 +0x38d
cmd/compile/internal/gc.dumpexport(0xc00008ecc0)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/export.go:79 +0x8f
cmd/compile/internal/gc.dumpCompilerObj(0xc00008ecc0)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/obj.go:119 +0x39
cmd/compile/internal/gc.dumpobj1(0x7ffcf3c1c508, 0x23, 0x3)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/obj.go:70 +0x15b
cmd/compile/internal/gc.dumpobj()
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/obj.go:51 +0x60
cmd/compile/internal/gc.Main(0xc209c8)
	/home/mhilton/opt/go/src/cmd/compile/internal/gc/main.go:684 +0x299a
main.main()
	/home/mhilton/opt/go/src/cmd/compile/main.go:49 +0x96

FAIL	local/a [build failed]
@agnivade agnivade added this to the Go1.11 milestone Apr 26, 2018
@agnivade agnivade added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 26, 2018
@mvdan
Copy link
Member

mvdan commented Apr 26, 2018

This seems to be in the code added by @mdempsky for the new indexed export format, so it's probably best if he has a look.

@mvdan mvdan added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 26, 2018
@griesemer griesemer self-assigned this Jun 5, 2018
@griesemer
Copy link
Contributor

Simpler. Compiling this package causes the error. The problem is a possibly overly strict check in the exported. The solution may be as simple as exporting ".anonX" named parameters as "".

package p

type T interface {
	M(int)
}

var x T
var M = x.M

@gopherbot
Copy link

Change https://golang.org/cl/116376 mentions this issue: cmd/compile: revert internal parameter rename (from ".anonX" to "") before export

@golang golang locked and limited conversation to collaborators Jun 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

7 participants