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: weird Sym #47896

Closed
1995parham opened this issue Aug 22, 2021 · 6 comments
Closed

cmd/compile: internal compiler error: weird Sym #47896

1995parham opened this issue Aug 22, 2021 · 6 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@1995parham
Copy link

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

$ gotip version
go version devel go1.18-6416bde Sun Aug 22 13:54:24 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/parham/.cache/go-build"
GOENV="/home/parham/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/parham/Documents/Go/pkg/mod"
GONOPROXY="gitlab.snapp.ir"
GONOSUMDB="gitlab.snapp.ir"
GOOS="linux"
GOPATH="/home/parham/Documents/Go"
GOPRIVATE="gitlab.snapp.ir"
GOPROXY="https://goproxy.io,direct"
GOROOT="/home/parham/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/parham/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-6416bde Sun Aug 22 13:54:24 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/parham/Downloads/linkedlist.go/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-build1063418849=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I have written the following generic code which is related to a linked list.

package list

import "github.com/1995parham/linkedlist/pkg/node"

type List[T any] struct {
        Head *node.Node[T]
}

func New[T any]() *List[T] {
        return &List[T]{
                Head: nil,
        }
}

func (l *List[T]) PushFront(data T) {
        nn := node.New(data)
        if l.Head == nil {
                l.Head = nn
        } else {
                nn.Next = l.Head
                l.Head = nn
        }
}

and the following code as a test.

package list

import "testing"

func TestListWith3Member(t *testing.T) {
        l := New[int]()

        l.PushFront(10)
}

What did you expect to see?

I expect the code passes the tests without issues.

What did you see instead?

# github.com/1995parham/linkedlist/pkg/list [github.com/1995parham/linkedlist/pkg/list.test]
<autogenerated>:1: internal compiler error: weird Sym: .dict.(*List[int]).PushFront, .dict.(*List[int]).PushFront

goroutine 1 [running]:
runtime/debug.Stack()
        /home/parham/sdk/gotip/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x6de4d8, 0xc0}, {0xcf6719, 0x11}, {0xc0000ef8a8, 0x2, 0x2})
        /home/parham/sdk/gotip/src/cmd/compile/internal/base/print.go:227 +0x154
cmd/compile/internal/base.Fatalf(...)
        /home/parham/sdk/gotip/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/typecheck.(*iexporter).pushDecl(0xc0006de4d0, 0xc000109a00)
        /home/parham/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:429 +0xb8
cmd/compile/internal/typecheck.WriteExports({0xe48b00, 0xc000728840}, 0x1)
        /home/parham/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:294 +0x2b0
cmd/compile/internal/noder.WriteExports(0xc0006d29e0)
        /home/parham/sdk/gotip/src/cmd/compile/internal/noder/export.go:40 +0x7a
cmd/compile/internal/gc.dumpCompilerObj(0xc0006d29e0)
        /home/parham/sdk/gotip/src/cmd/compile/internal/gc/obj.go:107 +0x28
cmd/compile/internal/gc.dumpobj1({0x7ffc572ff78a, 0x23}, 0x3)
        /home/parham/sdk/gotip/src/cmd/compile/internal/gc/obj.go:63 +0x185
cmd/compile/internal/gc.dumpobj()
        /home/parham/sdk/gotip/src/cmd/compile/internal/gc/obj.go:44 +0x36
cmd/compile/internal/gc.Main(0xd1bee0)
        /home/parham/sdk/gotip/src/cmd/compile/internal/gc/main.go:322 +0x10d6
main.main()
        /home/parham/sdk/gotip/src/cmd/compile/main.go:55 +0xdd

FAIL    github.com/1995parham/linkedlist/pkg/list [build failed]
@seankhliao
Copy link
Member

what is in github.com/1995parham/linkedlist/pkg/node

@1995parham
Copy link
Author

I share it here.

package node

type Node[T any] struct {
	Data T
	Next *Node[T]
}


func New[T any](data T) *Node[T] {
	return &Node[T]{
		Data: data,
		Next: nil,
	}
}

@renthraysk
Copy link

Another instance of the error.
go version devel go1.18-8fff20ffeb Sat Aug 21 11:23:14 2021 +0000 linux/amd64

https://go2goplay.golang.org/p/BpN_3KWb98g

autogenerated>:1: internal compiler error: weird Sym: .dict.(*Repository[main.Actor]).query, .dict.(*Repository[main.Actor]).query

goroutine 1 [running]:
runtime/debug.Stack()
	/home/ren/sdk/gotip/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x767138, 0xc0}, {0xcf6719, 0x11}, {0xc0008078a8, 0x2, 0x2})
	/home/ren/sdk/gotip/src/cmd/compile/internal/base/print.go:227 +0x154
cmd/compile/internal/base.Fatalf(...)
	/home/ren/sdk/gotip/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/typecheck.(*iexporter).pushDecl(0xc000767130, 0xc0005b9a00)
	/home/ren/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:429 +0xb8
cmd/compile/internal/typecheck.WriteExports({0xe48ac0, 0xc000598540}, 0x1)
	/home/ren/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:294 +0x2b0
cmd/compile/internal/noder.WriteExports(0xc00075d280)
	/home/ren/sdk/gotip/src/cmd/compile/internal/noder/export.go:40 +0x7a
cmd/compile/internal/gc.dumpCompilerObj(0xc00075d280)
	/home/ren/sdk/gotip/src/cmd/compile/internal/gc/obj.go:107 +0x28
cmd/compile/internal/gc.dumpobj1({0x7ffec203601a, 0x24}, 0x3)
	/home/ren/sdk/gotip/src/cmd/compile/internal/gc/obj.go:63 +0x185
cmd/compile/internal/gc.dumpobj()
	/home/ren/sdk/gotip/src/cmd/compile/internal/gc/obj.go:44 +0x36
cmd/compile/internal/gc.Main(0xd1bee0)
	/home/ren/sdk/gotip/src/cmd/compile/internal/gc/main.go:322 +0x10d6
main.main()
	/home/ren/sdk/gotip/src/cmd/compile/main.go:55 +0xdd

@seankhliao seankhliao changed the title Compiler Error on Generic Method cmd/compile: internal compiler error: weird Sym Aug 23, 2021
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 23, 2021
@komuw
Copy link
Contributor

komuw commented Aug 23, 2021

running gotip with export GOEXPERIMENT=unified seems to fix this

@1995parham
Copy link
Author

1995parham commented Aug 23, 2021

Yes, it causes the success compile. can you please share any document about the unified feature?

@danscales danscales self-assigned this Aug 23, 2021
@gopherbot
Copy link

Change https://golang.org/cl/344609 mentions this issue: cmd/compile: reuse same node for global dictionaries

@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 NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants