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

SSA dump via GOSSAFUNC on macOS crashes during HTML write #41584

Closed
anqurvanillapy opened this issue Sep 23, 2020 · 3 comments
Closed

SSA dump via GOSSAFUNC on macOS crashes during HTML write #41584

anqurvanillapy opened this issue Sep 23, 2020 · 3 comments

Comments

@anqurvanillapy
Copy link

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

$ go version
go version go1.15.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes, since 1.15.2 is the latest stable release.

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/xxx/Library/Caches/go-build"
GOENV="/Users/xxx/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/path/to/gopath/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/path/to/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/path/to/gopath/go/src/github.com/anqurvanillapy/xxx/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ht/0xdbpqwx5236z5p7q9y7s2wm0000gn/T/go-build530521061=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Try to dump SSAs from a simple hello-world script.

package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello, Go compiler!")
}
$ env GOSSAFUNC=main go build main.go

What did you expect to see?

The ssa.html is generated in the same directory.

What did you see instead?

$ env GOSSAFUNC=main go build main.go
# runtime
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0x1270567]

goroutine 7 [running]:
cmd/compile/internal/ssa.(*Func).Fatalf(...)
        /usr/local/go/src/cmd/compile/internal/ssa/func.go:625
cmd/compile/internal/ssa.NewHTMLWriter(0x1843bff, 0x8, 0xc00577e420, 0x0, 0x0, 0x1)
        /usr/local/go/src/cmd/compile/internal/ssa/html.go:33 +0xe7
cmd/compile/internal/gc.buildssa(0xc001954840, 0x1, 0x0)
        /usr/local/go/src/cmd/compile/internal/gc/ssa.go:342 +0x1172
cmd/compile/internal/gc.compileSSA(0xc001954840, 0x1)
        /usr/local/go/src/cmd/compile/internal/gc/pgen.go:317 +0x5d
cmd/compile/internal/gc.compileFunctions.func2(0xc00447cc00, 0xc000b91c90, 0x1)
        /usr/local/go/src/cmd/compile/internal/gc/pgen.go:382 +0x4d
created by cmd/compile/internal/gc.compileFunctions
        /usr/local/go/src/cmd/compile/internal/gc/pgen.go:380 +0x129
@cuonglm
Copy link
Member

cuonglm commented Sep 23, 2020

Duplicate of #40919

@anqurvanillapy
Copy link
Author

Duplicate of #40919

Thanks for your reply! Close due to duplication.

@anqurvanillapy
Copy link
Author

Until the release of 1.16, avoid name collisions with stdlib for the target function, e.g.

package main

import (
	"fmt"
)

func hello() {
	fmt.Println("Hello, Go compiler!")
}

func main() {
	hello()
}

Then

$ env GOSSAFUNC=hello go build main.go
# command-line-arguments
dumped SSA to ./ssa.html

@golang golang locked and limited conversation to collaborators Sep 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants