Skip to content

gccgo: internal compiler error: in set_type_index #52841

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

Closed
ddaa2000 opened this issue May 11, 2022 · 3 comments
Closed

gccgo: internal compiler error: in set_type_index #52841

ddaa2000 opened this issue May 11, 2022 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ddaa2000
Copy link

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

$ go version
go version go1.18.1 linux/amd64
$ gccgo --version
gccgo (GCC) 12.1.0

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="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://mirrors.aliyun.com/goproxy/"
GOROOT="/usr/local/go1.18.1"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go1.18.1/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="/usr/local/gcc-12.1.0/bin/gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/gosmith/bugReview/template0/go.mod"
GOWORK=""
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-build3110484687=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://go.dev/play/p/lU3CSLY5h5F
using gccgo:
go build -compiler=gccgo -gccgoflags="-static-libgo

What did you expect to see?

Compile successfully.

What did you see instead?

bugReview

go1: internal compiler error: in set_type_index, at go/gofrontend/export.cc:741
0x753287 Export::set_type_index(Type const*)
../../gcc-12.1.0/gcc/go/gofrontend/export.cc:741
0x7c2517 Export::assign_type_indices(std::vector<Named_object*, std::allocator<Named_object*> > const&)
../../gcc-12.1.0/gcc/go/gofrontend/export.cc:789
0x7c3a91 Export::export_globals(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::map<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, Package*, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, Package*> > > const&, std::map<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, Package*, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, Package*> > > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, Import_init_set const&, Bindings const*, std::unordered_set<Named_object*, std::hash<Named_object*>, std::equal_to<Named_object*>, std::allocator<Named_object*> >*)
../../gcc-12.1.0/gcc/go/gofrontend/export.cc:645
0x81e787 Gogo::do_exports()
../../gcc-12.1.0/gcc/go/gofrontend/gogo.cc:5231
0x80e8bb go_parse_input_files(char const**, unsigned int, bool, bool)
../../gcc-12.1.0/gcc/go/gofrontend/go.cc:159
0x80a03f go_langhook_parse_file
../../gcc-12.1.0/gcc/go/go-lang.cc:359
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See https://gcc.gnu.org/bugs/ for instructions.

@gopherbot gopherbot added this to the Gccgo milestone May 11, 2022
@heschi
Copy link
Contributor

heschi commented May 11, 2022

cc @ianlancetaylor

@heschi heschi added the NeedsFix The path to resolution is known, but the work has not been done. label May 11, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/405759 mentions this issue: test: add test case that caused a gofrontend crash

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/405556 mentions this issue: compiler: always sort interface parse methods

@ianlancetaylor ianlancetaylor self-assigned this May 12, 2022
@ianlancetaylor ianlancetaylor changed the title gccgo:internal compiler error: in set_type_index gccgo: internal compiler error: in set_type_index May 12, 2022
gopherbot pushed a commit that referenced this issue May 12, 2022
For #52841

Change-Id: If4723a70fba0dbedb5d1e70dab58f0b4612bf8b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/405759
Auto-Submit: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
xionghul pushed a commit to xionghul/gcc that referenced this issue May 13, 2022
The exporter relies on sorting interface parse methods.  It would sort
them as it encountered interface types.  However, when an interface
type is an element of a struct or array type, the exporter might
encounter that interface type before sorting the parse methods.  If it
then encountered an identical interface type again, it could get
confused about whether the two types are identical or not.

Fix the problem by always sorting the parse methods in the
finalize_methods pass.

Also firm up the export type sorting to make sure we never have this
kind of confusion again.  Doing this revealed that we need to be more
careful about sorting in order to handle aliases correctly.

Also fix the interface type hash computation to use the right hash
value when looking at parse methods rather than all methods.

The test case for this is https://go.dev/cl/405759.

Fixes golang/go#52841

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/405556
realqhc pushed a commit to realqhc/gofrontend that referenced this issue Aug 4, 2022
The exporter relies on sorting interface parse methods.  It would sort
them as it encountered interface types.  However, when an interface
type is an element of a struct or array type, the exporter might
encounter that interface type before sorting the parse methods.  If it
then encountered an identical interface type again, it could get
confused about whether the two types are identical or not.

Fix the problem by always sorting the parse methods in the
finalize_methods pass.

Also firm up the export type sorting to make sure we never have this
kind of confusion again.  Doing this revealed that we need to be more
careful about sorting in order to handle aliases correctly.

Also fix the interface type hash computation to use the right hash
value when looking at parse methods rather than all methods.

The test case for this is https://go.dev/cl/405759.

Fixes golang/go#52841

Change-Id: I6243246148dbd96df8d2f2244516443d9bd6b114
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/405556
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Than McIntosh <[email protected]>
@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants