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/go2go: SIGSEGV while comparing exported variables #39878

Closed
kovetskiy opened this issue Jun 26, 2020 · 3 comments
Closed

cmd/go2go: SIGSEGV while comparing exported variables #39878

kovetskiy opened this issue Jun 26, 2020 · 3 comments

Comments

@kovetskiy
Copy link

@kovetskiy kovetskiy commented Jun 26, 2020

go version devel +4dfbf5ab9c7 Thu Jun 25 02:57:14 2020 +0000 linux/amd64

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

goroutine 1 [running]:
go/types.(*Package).Scope(...)
        /usr/lib/go/src/go/types/package.go:42
go/go2go.(*translator).instantiationTypes(0xc000167698, 0xc00011a380, 0x0, 0xc00000c3e0, 0x2, 0xc000126ba0, 0xc000167010, 0x526bec, 0x650900)
        /usr/lib/go/src/go/go2go/rewrite.go:1035 +0x109
go/go2go.(*translator).translateFunctionInstantiation(0xc000167698, 0xc0000685e0)
        /usr/lib/go/src/go/go2go/rewrite.go:872 +0xa7
go/go2go.(*translator).translateExpr(0xc000167698, 0xc0000685e0)
        /usr/lib/go/src/go/go2go/rewrite.go:680 +0x3cc
go/go2go.(*translator).translateStmt(0xc000167698, 0xc0000685f0)
        /usr/lib/go/src/go/go2go/rewrite.go:575 +0x3ac
go/go2go.(*translator).translateBlockStmt(0xc000167698, 0xc000010bd0)
        /usr/lib/go/src/go/go2go/rewrite.go:544 +0x57
go/go2go.(*translator).translateFuncDecl(0xc000167698, 0xc00011a3e0)
        /usr/lib/go/src/go/go2go/rewrite.go:534 +0xc5
go/go2go.(*translator).translate(0xc000167698, 0xc000024200)
        /usr/lib/go/src/go/go2go/rewrite.go:461 +0x391
go/go2go.rewriteAST(0xc00011a240, 0xc0000743c0, 0x0, 0x0, 0xc00007f6d0, 0xc000024200, 0x7f48a7eba201, 0xc000144420, 0x817bc0)
        /usr/lib/go/src/go/go2go/rewrite.go:257 +0xe5
go/go2go.rewriteFile(0xc000016460, 0x17, 0xc00011a240, 0xc0000743c0, 0x0, 0x0, 0xc00007f6d0, 0xc0000164e0, 0x20, 0xc000024200, ...)
        /usr/lib/go/src/go/go2go/rewrite.go:221 +0xb8
go/go2go.rewriteFilesInPath(0xc0000743c0, 0x0, 0x0, 0xc000016460, 0x17, 0xc000068490, 0x1, 0x1, 0x0, 0x0, ...)
        /usr/lib/go/src/go/go2go/go2go.go:106 +0xbd1
go/go2go.rewriteToPkgs(0xc0000743c0, 0x0, 0x0, 0xc000016460, 0x17, 0xc0000101a0, 0xc000016460, 0x17, 0x7ffe50c6ac41, 0x8)
        /usr/lib/go/src/go/go2go/go2go.go:46 +0x165
go/go2go.Rewrite(...)
        /usr/lib/go/src/go/go2go/go2go.go:30
main.translate(0xc0000743c0, 0xc000016460, 0x17)
        /usr/lib/go/src/cmd/go2go/translate.go:15 +0x47
main.main()
        /usr/lib/go/src/cmd/go2go/main.go:54 +0xb25

package main

import "errors"

var (
	A = errors.New("a")
	B = errors.New("b")
)

func main() {
	x(A, B)
}

func x(type T comparable)(a, b T) {
	_ = a == b
}

@ALTree ALTree changed the title go2go translator: SIGSERV while comparing exported variables go2go translator: SIGSEGV while comparing exported variables Jun 26, 2020
@kovetskiy
Copy link
Author

@kovetskiy kovetskiy commented Jun 26, 2020

Also checked on
go version devel +1b08acee45f Thu Jun 25 23:22:18 2020 +0000 linux/amd64

@ianlancetaylor ianlancetaylor changed the title go2go translator: SIGSEGV while comparing exported variables cmd/go2go: SIGSEGV while comparing exported variables Jun 26, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 26, 2020

Change https://golang.org/cl/240013 mentions this issue: [dev.go2go] go/go2go: avoid crashing on predeclared error type

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 26, 2020

Thanks for the test case. This is now fixed on the dev.go2go branch.

gopherbot pushed a commit that referenced this issue Jun 26, 2020
It has no package, so we need to check for Pkg() == nil.

Fixes #39878

Change-Id: I14a47c5098f97ce42dfa8cc875819f244a2b0201
Reviewed-on: https://go-review.googlesource.com/c/go/+/240013
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.