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: missing import reader for cc.noder.Position #49016

Closed
danp opened this issue Oct 16, 2021 · 5 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@danp
Copy link
Contributor

danp commented Oct 16, 2021

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

$ go version
go version devel go1.18-640a49b8d4 Sat Oct 16 16:27:40 2021 +0000 darwin/arm64

Does this issue reproduce with the latest release?

No

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/dan/Library/Caches/go-build"
GOENV="/Users/dan/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/dan/Library/Caches/go-mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/dan/src"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/dan/src/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/dan/src/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="devel go1.18-640a49b8d4 Sat Oct 16 16:27:40 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/dan/x/tmp/ccgo/v3/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cp/3cmnrnds4j72mrgplhz2wr0w0000gn/T/go-build170542352=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

git clone https://gitlab.com/cznic/ccgo.git 
cd ccgo/v3/lib
go test

What did you expect to see?

execute /Users/dan/src/go/bin/go ["mod" "init" "example.com/ccgo/v3/lib/tcc"] in /private/var/folders/cp/3cmnrnds4j72mrgplhz2wr0w0000gn/T/ccgo-test-290052703
go: creating new go.mod: module example.com/ccgo/v3/lib/tcc
execute /Users/dan/src/go/bin/go ["get" "modernc.org/libc"] in /private/var/folders/cp/3cmnrnds4j72mrgplhz2wr0w0000gn/T/ccgo-test-290052703
go: downloading github.com/google/uuid v1.3.0
go: added github.com/google/uuid v1.3.0
go: added github.com/mattn/go-isatty v0.0.12
go: added github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0
go: added golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac
go: added modernc.org/libc v1.11.33
go: added modernc.org/mathutil v1.4.1
go: added modernc.org/memory v1.0.5
...

What did you see instead?

# modernc.org/ccgo/v3/lib [modernc.org/ccgo/v3/lib.test]
<autogenerated>:1: internal compiler error: missing import reader for cc.noder.Position

goroutine 1 [running]:
runtime/debug.Stack()
	/Users/dan/src/go/src/runtime/debug/stack.go:24 +0x68
cmd/compile/internal/base.FatalfAt({0x157a720, 0x1}, {0x1013dda28, 0x1c}, {0x14004a1db18, 0x1, 0x1})
	/Users/dan/src/go/src/cmd/compile/internal/base/print.go:227 +0x20c
cmd/compile/internal/base.Fatalf(...)
	/Users/dan/src/go/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/typecheck.ImportBody(0x14003470c60)
	/Users/dan/src/go/src/cmd/compile/internal/typecheck/iimport.go:73 +0x1a8
cmd/compile/internal/typecheck.ImportedBody(0x14003470c60)
	/Users/dan/src/go/src/cmd/compile/internal/typecheck/func.go:169 +0x88
cmd/compile/internal/inline.oldInline(0x14005925d40, 0x14003470c60, 0x48e)
	/Users/dan/src/go/src/cmd/compile/internal/inline/inl.go:802 +0x48
cmd/compile/internal/inline.mkinlcall(0x14005925d40, 0x14003470c60, 0x4a1e108, 0x14003eb07e0, 0x0)
	/Users/dan/src/go/src/cmd/compile/internal/inline/inl.go:754 +0xae4
cmd/compile/internal/inline.inlnode({0x1015f3488, 0x14005925d40}, 0x0, 0x14005939d00, 0x14004a1e1c8)
	/Users/dan/src/go/src/cmd/compile/internal/inline/inl.go:611 +0x4dc
cmd/compile/internal/inline.InlineCalls.func1({0x1015f3488, 0x14005925d40})
	/Users/dan/src/go/src/cmd/compile/internal/inline/inl.go:530 +0x38
cmd/compile/internal/ir.editNodes({0x14005939ce0, 0x1, 0x1015f4fe0}, 0x1400594ec20)
	/Users/dan/src/go/src/cmd/compile/internal/ir/node_gen.go:1521 +0x74
cmd/compile/internal/ir.(*ReturnStmt).editChildren(0x14005953f90, 0x14005953f90)
	/Users/dan/src/go/src/cmd/compile/internal/ir/node_gen.go:1056 +0x58
cmd/compile/internal/ir.EditChildren(...)
	/Users/dan/src/go/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/inline.inlnode({0x1015f4fe0, 0x14005953f90}, 0x4a1e368, 0x100c5b830, 0x1400594ec20)
	/Users/dan/src/go/src/cmd/compile/internal/inline/inl.go:590 +0x3c0
cmd/compile/internal/inline.InlineCalls.func1({0x1015f4fe0, 0x14005953f90})
	/Users/dan/src/go/src/cmd/compile/internal/inline/inl.go:530 +0x38
cmd/compile/internal/ir.editNodes({0x14005939cf0, 0x1, 0x140058df301}, 0x1400594ec20)
	/Users/dan/src/go/src/cmd/compile/internal/ir/node_gen.go:1521 +0x74
cmd/compile/internal/ir.(*Func).editChildren(0x1015f4fe0, 0x14005953f90)
	/Users/dan/src/go/src/cmd/compile/internal/ir/func.go:153 +0x38
cmd/compile/internal/ir.EditChildren(...)
	/Users/dan/src/go/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/inline.InlineCalls(0x140058df340)
	/Users/dan/src/go/src/cmd/compile/internal/inline/inl.go:532 +0xf8
cmd/compile/internal/reflectdata.methodWrapper(0x140015a88c0, 0x140059531d0, 0x98)
	/Users/dan/src/go/src/cmd/compile/internal/reflectdata/reflect.go:1955 +0x15a4
cmd/compile/internal/reflectdata.methods(0x140015a88c0)
	/Users/dan/src/go/src/cmd/compile/internal/reflectdata/reflect.go:350 +0x334
cmd/compile/internal/reflectdata.writeITab(0x14005954200, 0x140015a88c0, 0x14002d929a0)
	/Users/dan/src/go/src/cmd/compile/internal/reflectdata/reflect.go:1298 +0x264
cmd/compile/internal/reflectdata.ITabAddr(0x14002d929a0, 0x14003584fc0)
	/Users/dan/src/go/src/cmd/compile/internal/reflectdata/reflect.go:867 +0x19c
cmd/compile/internal/walk.walkDotType(0x14003584f00, 0x100de4ddc)
	/Users/dan/src/go/src/cmd/compile/internal/walk/expr.go:678 +0xc4
cmd/compile/internal/walk.walkExpr1({0x1015f5940, 0x14003584f00}, 0x14003584f00)
	/Users/dan/src/go/src/cmd/compile/internal/walk/expr.go:137 +0x728
cmd/compile/internal/walk.walkExpr({0x1015f5940, 0x14003584f00}, 0x14004a1eeb0)
	/Users/dan/src/go/src/cmd/compile/internal/walk/expr.go:55 +0x370
cmd/compile/internal/walk.walkAssign(0x14004a1eeb0, {0x1015f30a0, 0x140059454f0})
	/Users/dan/src/go/src/cmd/compile/internal/walk/assign.go:72 +0x8d8
cmd/compile/internal/walk.walkExpr1({0x1015f30a0, 0x140059454f0}, 0x140059454f0)
	/Users/dan/src/go/src/cmd/compile/internal/walk/expr.go:179 +0x3f8
cmd/compile/internal/walk.walkExpr({0x1015f30a0, 0x140059454f0}, 0x14004a1eeb0)
	/Users/dan/src/go/src/cmd/compile/internal/walk/expr.go:55 +0x370
cmd/compile/internal/walk.walkStmt({0x1015f30a0, 0x140059454f0})
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:57 +0x650
cmd/compile/internal/walk.walkStmtList({0x14005935a00, 0x5, 0x140019afba0})
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:175 +0x6c
cmd/compile/internal/walk.walkIf(0x140019afb90)
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:228 +0x78
cmd/compile/internal/walk.walkStmt({0x1015f4108, 0x140019afb90})
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:131 +0x2a8
cmd/compile/internal/walk.walkStmtList({0x140058edc00, 0x1c, 0x14005945630})
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:175 +0x6c
cmd/compile/internal/walk.walkExpr({0x1015f3a00, 0x14005945630}, 0x14001c4e0f0)
	/Users/dan/src/go/src/cmd/compile/internal/walk/expr.go:37 +0xc4
cmd/compile/internal/walk.walkIf(0x14001c4e0e0)
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:227 +0x34
cmd/compile/internal/walk.walkStmt({0x1015f4108, 0x14001c4e0e0})
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:131 +0x2a8
cmd/compile/internal/walk.walkStmtList({0x1400594e200, 0x2, 0x14004a1f3c0})
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:175 +0x6c
cmd/compile/internal/walk.walkFor(0x14005925680)
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:192 +0x164
cmd/compile/internal/walk.walkStmt({0x1015f3d20, 0x14005925680})
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:127 +0x26c
cmd/compile/internal/walk.walkRange(0x14001c3d950)
	/Users/dan/src/go/src/cmd/compile/internal/walk/range.go:311 +0x3c24
cmd/compile/internal/walk.walkStmt({0x1015f4d88, 0x14001c3d950})
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:165 +0x324
cmd/compile/internal/walk.walkStmtList({0x1400594c000, 0x42, 0x140033934a0})
	/Users/dan/src/go/src/cmd/compile/internal/walk/stmt.go:175 +0x6c
cmd/compile/internal/walk.Walk(0x140033934a0)
	/Users/dan/src/go/src/cmd/compile/internal/walk/walk.go:43 +0x128
cmd/compile/internal/gc.prepareFunc(0x140033934a0)
	/Users/dan/src/go/src/cmd/compile/internal/gc/compile.go:92 +0x84
cmd/compile/internal/gc.enqueueFunc(0x140033934a0)
	/Users/dan/src/go/src/cmd/compile/internal/gc/compile.go:66 +0x29c
cmd/compile/internal/gc.Main(0x1015eb9e0)
	/Users/dan/src/go/src/cmd/compile/internal/gc/main.go:308 +0xfb8
main.main()
	/Users/dan/src/go/src/cmd/compile/main.go:55 +0xf8

FAIL	modernc.org/ccgo/v3/lib [build failed]
@danp
Copy link
Contributor Author

danp commented Oct 16, 2021

Sorry I don't have a smaller repro, I haven't dug in yet to try and see where this is happening.

Maybe related to #48454?

@ALTree ALTree added this to the Go1.18 milestone Oct 16, 2021
@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 16, 2021
@danscales
Copy link
Contributor

I didn't get the actual test to run completely successfully in Go 1.17 (see below, some module dependency error?), but I confirmed that 'go test -c' works fine, whereas 'go test -c' fails with the above error in Go 1.18. So, this confirms that the test does not include any parameterized types or functions (as expected, but just to be clear). Maybe this relates to some changes that we have made in crawler.go or in the export format in the Go 1.18 timeframe? Will have to dig some more.

@randall77 @mdempsky

Error message when running test with Go 1.17:

            module mode error: -: no required module provides package modernc.org/libc: go.mod file not found in current directory or any parent directory; see 'go help modules'

execute bin/go ["mod" "init" "example.com/ccgo/v3/lib/compcert"] in /tmp/ccgo-test-1543161118

@cuonglm cuonglm self-assigned this Oct 18, 2021
@cuonglm cuonglm added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 18, 2021
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 18, 2021
@cuonglm
Copy link
Member

cuonglm commented Oct 18, 2021

This starts failing since https://go-review.googlesource.com/c/go/+/327871

The problem is that in https://go-review.googlesource.com/c/go/+/327872, we fixed crawling of embeddable types, so CL 327871 unconditionally call inline.InlineCalls inside methodWrapper. But the crawler only mark embed for reachable declared type name, it misses the case that anonymous types are used during dot type.

I'm going to submit a CL to fix this.

@gopherbot
Copy link

Change https://golang.org/cl/356254 mentions this issue: cmd/compile: fix crawling of embeddable types during inline

@danp
Copy link
Contributor Author

danp commented Oct 18, 2021

@danscales Failures with 1.17 may need more digging into, sometimes local config is needed. go test -c was a good check, thanks for that.

@cuonglm Tried your CL and was able to go test -c with it. Thanks!

@rsc rsc unassigned cuonglm Jun 23, 2022
@golang golang locked and limited conversation to collaborators Jun 23, 2023
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.
Projects
None yet
Development

No branches or pull requests

5 participants