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

Segmentation fault during compilation #45687

Closed
benkasminbullock opened this issue Apr 22, 2021 · 4 comments
Closed

Segmentation fault during compilation #45687

benkasminbullock opened this issue Apr 22, 2021 · 4 comments

Comments

@benkasminbullock
Copy link

benkasminbullock commented Apr 22, 2021

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

$ go version
go version go1.16.3 freebsd/386

Does this issue reproduce with the latest release?

This is the latest release on FreeBSD, I checked using pkg upgrade before filing.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="386"
GOBIN=""
GOCACHE="/home/ben/.cache/go-build"
GOENV="/home/ben/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="386"
GOHOSTOS="freebsd"
GOINSECURE=""
GOMODCACHE="/home/ben/software/golib/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="freebsd"
GOPATH="/home/ben/software/golib"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/freebsd_386"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
GO386="sse2"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/home/ben/oneoff/gobug/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 -m32 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1777355294=/tmp/go-build -gno-record-gcc-switches"

What did you do?

The files are here:

https://github.com/benkasminbullock/gobug

I'm able to reproduce the bug from the local repo.

What did you expect to see?

Successful compilation.

What did you see instead?

go build -o ln-http ln-http.go lang2name.go
# command-line-arguments
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x85b9c36]

goroutine 1 [running]:
cmd/compile/internal/gc.findTypeLoop(0x393515c0, 0x393872a0, 0x7fffff00)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:202 +0xc6
cmd/compile/internal/gc.findTypeLoop(0x39351540, 0x393872a0, 0x38ed4300)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:216 +0x21f
cmd/compile/internal/gc.findTypeLoop(0x39351500, 0x393872a0, 0x0)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:202 +0xd5
cmd/compile/internal/gc.findTypeLoop(0x39525440, 0x393872a0, 0x0)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:216 +0x21f
cmd/compile/internal/gc.findTypeLoop(0x39525400, 0x393872a0, 0x39347e5d)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:202 +0xd5
cmd/compile/internal/gc.reportTypeLoop(0x39525400)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:240 +0x62
cmd/compile/internal/gc.dowidth(0x39525400)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:282 +0x113a
cmd/compile/internal/gc.widstruct(0x39351500, 0x39351500, 0x0, 0x0, 0x1, 0x0, 0x3)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:114 +0xb1
cmd/compile/internal/gc.dowidth(0x39351500)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:435 +0x52c
cmd/compile/internal/gc.widstruct(0x39525400, 0x39525400, 0x0, 0x0, 0x1, 0x28c5efff, 0x805a330)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:114 +0xb1
cmd/compile/internal/gc.dowidth(0x39525400)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:435 +0x52c
cmd/compile/internal/gc.widstruct(0x39351540, 0x39351540, 0x0, 0x0, 0x1, 0x6, 0x39023500)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:114 +0xb1
cmd/compile/internal/gc.dowidth(0x39351540)
	/usr/local/go/src/cmd/compile/internal/gc/align.go:435 +0x52c
cmd/compile/internal/gc.resumecheckwidth()
	/usr/local/go/src/cmd/compile/internal/gc/align.go:526 +0x38
cmd/compile/internal/gc.typecheckdef(0x39348510)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:3695 +0x79b
cmd/compile/internal/gc.typecheck1(0x39348510, 0x4, 0x0)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:343 +0xa872
cmd/compile/internal/gc.typecheck(0x39348510, 0x4, 0x0)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:299 +0x67c
cmd/compile/internal/gc.typecheck1(0x392aaf50, 0x1, 0x0)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:2077 +0x469f
cmd/compile/internal/gc.typecheck(0x392aaf50, 0x1, 0x0)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:299 +0x67c
cmd/compile/internal/gc.Main(0x87db970)
	/usr/local/go/src/cmd/compile/internal/gc/main.go:603 +0x276d
main.main()
	/usr/local/go/src/cmd/compile/main.go:52 +0x8d
*** Error code 2

Stop.
@cuonglm
Copy link
Member

cuonglm commented Apr 22, 2021

Duplicated of #44266

@benkasminbullock
Copy link
Author

The crash is due to the circular lnhttp -> lnresponse -> lnhttp inclusion of structs.

@randall77
Copy link
Contributor

I'll close - we believe this is fixed at tip, and fixing a compiler crash on an invalid program is not worth the risk of backporting.
Please reopen if you think this isn't fixed at tip, or if you think your program is valid.

@benkasminbullock
Copy link
Author

I'll close - we believe this is fixed at tip, and fixing a compiler crash on an invalid program is not worth the risk of backporting.
Please reopen if you think this isn't fixed at tip, or if you think your program is valid.

OK, obviously the program is not valid but a segmentation fault is not a good response. Anyway I assume this will create a better error message in the new version.

I've set the repo containing my code to private, if you need that again for some reason ping me and I'll open it up again.

@golang golang locked and limited conversation to collaborators Apr 22, 2022
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

4 participants