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

gccgo: building non-empty struct with zero-sized trailing fields failed #34912

Open
erifan opened this issue Oct 15, 2019 · 1 comment
Open

gccgo: building non-empty struct with zero-sized trailing fields failed #34912

erifan opened this issue Oct 15, 2019 · 1 comment
Assignees
Labels
Milestone

Comments

@erifan
Copy link
Contributor

@erifan erifan commented Oct 15, 2019

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

go version go1.13 gollvm LLVM 10.0.0svn 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/hostname/.cache/go-build"
GOENV="/home/hostname/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/hostname/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/hostname/gollvm-master/install"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/hostname/gollvm-master/install/tools"
GCCGO="/home/hostname/gollvm-master/install/bin/llvm-goc"
AR="ar"
CC="/usr/bin/cc"
CXX="/usr/bin/c++"
CGO_ENABLED="1"
GOMOD=""
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-build409229965=/tmp/go-build -gno-record-gcc-switches -funwind-tables"

What did you do?

https://play.golang.org/p/9QxcZb4KPJh

Build and run the above code with gccgo (gcc backend) and gollvm go (llvm backend)

What did you expect to see?

Nothing output.

What did you see instead?

For gollvm go, the error messages are as follow:
llvm-goc: ./gollvm-master/llvm/tools/gollvm/bridge/go-llvm-materialize.cpp:860: Bexpression* Llvm_backend::materializeComposite(Bexpression*): Assertion `vals.size() == numElements' failed.

For gccgo, the error messages are as follow:
go1: internal compiler error: in return_statement, at go/go-gcc.cc:2168
Please submit a full bug report,
with preprocessed source if appropriate.
See file:///usr/share/doc/gcc-9/README.Bugs for instructions.

A simple profiling:
For non-empty struct with zero-sized trailing fields, we add an extra field "_" to it in gofrontend/go/types.cc:get_backend_struct_fields. But the Bexpression of the results has the same element size with the original results sequence. So the assert failed. I didn't dig into the gccgo code, but I guess the cause of this issue should be the same. There are multiple such assertions in gollvm code, simply removing them don't work. I don't know how gc go handles this case, but gc go can really handle this case.
CC @ianlancetaylor @thanm @cherrymui

@gopherbot gopherbot added this to the Gccgo milestone Oct 15, 2019
@erifan erifan added the NeedsFix label Oct 15, 2019
@thanm thanm self-assigned this Oct 15, 2019
@thanm
Copy link
Member

@thanm thanm commented Oct 15, 2019

Thanks for reporting this. I'll take a look.

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
3 participants
You can’t perform that action at this time.