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: internal error in type_index, export.cc:1265 #34577

Closed
thanm opened this issue Sep 27, 2019 · 3 comments
Closed

gccgo: internal error in type_index, export.cc:1265 #34577

thanm opened this issue Sep 27, 2019 · 3 comments
Milestone

Comments

@thanm
Copy link
Contributor

thanm commented Sep 27, 2019

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

gccgo tip

$ go version
go version go1.13 gccgo (GCC) 10.0.0 20190916 (experimental) linux/amd64

Does this issue reproduce with the latest release?

yes

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

linux/amd64

What did you do?

Compile these two packages:

Package "a":

package a

type A struct {
	x int
}

//go:noinline
func W(a A, k, v interface{}) A {
	return A{3}
}

Package "b":

package b

import "a"

type B struct {
	s string
}

func (b B) Func(x a.A) a.A {
	return a.W(x, k, b)
}

type ktype int

const k ktype = 0

What did you expect to see?

clean compile

What did you see instead?

ICE with this stack trace:

go1: internal compiler error: in type_index, at go/gofrontend/export.cc:1265
0x8440c5 Export::type_index(Type const*)
	../../gcc-trunk/gcc/go/gofrontend/export.cc:1265
0x84419d Export::write_type_to(Type const*, Export_function_body*)
	../../gcc-trunk/gcc/go/gofrontend/export.cc:1287
0x8553b3 Export_function_body::write_type(Type const*)
	../../gcc-trunk/gcc/go/gofrontend/export.h:345
0x8553b3 Integer_expression::do_export(Export_function_body*) const
	../../gcc-trunk/gcc/go/gofrontend/expressions.cc:2531
0x850bb1 Expression::export_expression(Export_function_body*) const
	../../gcc-trunk/gcc/go/gofrontend/expressions.h:1054
0x850bb1 Type_conversion_expression::do_export(Export_function_body*) const
	../../gcc-trunk/gcc/go/gofrontend/expressions.cc:4268
0x85bbe7 Expression::export_expression(Export_function_body*) const
	../../gcc-trunk/gcc/go/gofrontend/expressions.h:1054
0x85bbe7 Call_expression::export_arguments(Export_function_body*) const
	../../gcc-trunk/gcc/go/gofrontend/expressions.cc:12398
0x88e96c Statement::export_statement(Export_function_body*)
	../../gcc-trunk/gcc/go/gofrontend/statements.h:340
0x88e96c Block::export_block(Export_function_body*)
	../../gcc-trunk/gcc/go/gofrontend/gogo.cc:6932
0x8d8f36 Block_statement::export_block(Export_function_body*, Block*, bool)
	../../gcc-trunk/gcc/go/gofrontend/statements.cc:2155
0x88e96c Statement::export_statement(Export_function_body*)
	../../gcc-trunk/gcc/go/gofrontend/statements.h:340
0x88e96c Block::export_block(Export_function_body*)
	../../gcc-trunk/gcc/go/gofrontend/gogo.cc:6932
0x89a8de Function::export_func_with_type(Export*, Named_object const*, Function_type const*, std::vector >*, bool, std::__cxx11::basic_string, std::allocator > const&, Block*, Location)
	../../gcc-trunk/gcc/go/gofrontend/gogo.cc:5987
0x89aed8 Function::export_func(Export*, Named_object const*) const
	../../gcc-trunk/gcc/go/gofrontend/gogo.cc:5841
0x89afa3 Named_object::export_named_object(Export*) const
	../../gcc-trunk/gcc/go/gofrontend/gogo.cc:8573
0x8e6efa Named_type::do_export(Export*) const
	../../gcc-trunk/gcc/go/gofrontend/types.cc:11132
0x84190a Type::export_type(Export*) const
	../../gcc-trunk/gcc/go/gofrontend/types.h:1076
0x84190a Export::write_type_definition(Type const*, int)
	../../gcc-trunk/gcc/go/gofrontend/export.cc:1206
0x841b8f Export::write_types(int)
	../../gcc-trunk/gcc/go/gofrontend/export.cc:1143

It looks as though the issue is with the constant, which is not getting picked up properly by the exporter.

Still working on a fix.

@thanm thanm added this to the Gccgo milestone Sep 27, 2019
@thanm thanm self-assigned this Sep 27, 2019
@gopherbot
Copy link

Change https://golang.org/cl/198017 mentions this issue: compiler: walk selected type conversions during export processing

@gopherbot
Copy link

Change https://golang.org/cl/198057 mentions this issue: test: new testcase for gccgo compiler problem

jpf91 pushed a commit to D-Programming-GDC/gcc that referenced this issue Oct 5, 2019
    
    The machinery that collects types referenced by expressions that are
    part of inlinable function bodies was missing the types of local named
    constants in certain cases. This patch updates the
    Collect_export_references::expression() hook to look for references to
    local named constants and include their types in the exported set.
    
    Fixes golang/go#34577.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/198017


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@276594 138bc75d-0d04-0410-961f-82ee72b054a4
gopherbot pushed a commit that referenced this issue Oct 9, 2019
Test case with code that caused a gccgo error while emitting export
data for an inlinable function.

Updates #34577.

Change-Id: I28b598c4c893c77f4a76bb4f2d27e5b42f702992
Reviewed-on: https://go-review.googlesource.com/c/go/+/198057
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/201017 mentions this issue: test: revise testcase for new gccgo compiler bug

gopherbot pushed a commit that referenced this issue Oct 14, 2019
Add to the testcase originally created for issue 34577 so
as to also trigger the error condition for issue 34852 (the
two bugs are closely related).

Updates #34577.
Updates #34852.

Change-Id: I2347369652ce500184347606b2bb3e76d802b204
Reviewed-on: https://go-review.googlesource.com/c/go/+/201017
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Oct 13, 2020
asiekierka pushed a commit to WonderfulToolchain/gcc-ia16 that referenced this issue May 16, 2022
    
    The machinery that collects types referenced by expressions that are
    part of inlinable function bodies was missing the types of local named
    constants in certain cases. This patch updates the
    Collect_export_references::expression() hook to look for references to
    local named constants and include their types in the exported set.
    
    Fixes golang/go#34577.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/198017

From-SVN: r276594
@rsc rsc unassigned thanm Jun 23, 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

2 participants