Skip to content

gollvm: crash compiling inlinable empty method #31637

Closed
@thanm

Description

@thanm

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

$ go version
go version go1.12.2 gollvm LLVM 9.0.0svn linux/amd64

Does this issue reproduce with the latest release?

Yes, happens with gollvm tip

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

linux/amd64

What did you do?

Compile the following pair of packages with gollvm:

First package:

package novarmethod

type dO struct {
	x int
}

type EDO struct{}

func (EDO) Apply(*dO) {}

var X EDO

Second package (depends on first)

package usenovarmethod

import "novarmethod"

type NoMumble struct {
	novarmethod.EDO
}

func X() NoMumble {
	return NoMumble{}
}

What did you expect to see?

Clean compilation

What did you see instead?

Compiler crash:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff67593fa in __GI_abort () at abort.c:89
#2  0x00007ffff6750e37 in __assert_fail_base (fmt=, assertion=assertion@entry=0x5555577d6536 "it != valueVarMap_.end()", file=file@entry=0x5555577d62c0 "/s/llvm/tools/gollvm/bridge/go-llvm-bfunction.cpp", line=line@entry=324, function=function@entry=0x5555577d71a0  "std::vector Bfunction::getParameterVars()") at assert.c:92
#3  0x00007ffff6750ee2 in __GI___assert_fail (assertion=0x5555577d6536 "it != valueVarMap_.end()", file=0x5555577d62c0 "/s/llvm/tools/gollvm/bridge/go-llvm-bfunction.cpp", line=324, function=0x5555577d71a0  "std::vector Bfunction::getParameterVars()") at assert.c:101
#4  0x000055555597c0c7 in Bfunction::getParameterVars (this=0x555559d1fe30) at /s/llvm/tools/gollvm/bridge/go-llvm-bfunction.cpp:324
#5  0x000055555599cf5c in DIBuildHelper::endFunction (this=0x55555997b160, function=0x555559d1fe30) at /s/llvm/tools/gollvm/bridge/go-llvm-dibuildhelper.cpp:198
#6  0x00005555558ddf55 in GenBlocks::finishFunction (this=0x7fffffffcbc0, entry=0x555559d43ab0) at /s/llvm/tools/gollvm/bridge/go-llvm.cpp:2841
#7  0x00005555558e1f93 in Llvm_backend::function_set_body (this=0x5555599763d0, function=0x555559d1fe30, code_stmt=0x555559d41c80) at /s/llvm/tools/gollvm/bridge/go-llvm.cpp:3860
#8  0x0000555555809166 in Function::build (this=0x555559b36820, gogo=0x55555997b460, named_function=0x555559a99710) at /s/llvm/tools/gollvm/gofrontend/go/gogo.cc:6204
#9  0x000055555580f5e7 in Named_object::get_backend (this=0x555559a99710, gogo=0x55555997b460, const_decls=std::vector of length 0, capacity 0, type_decls=std::vector of length 2, capacity 2 = {...}, func_decls=std::vector of length 12, capacity 16 = {...}) at /s/llvm/tools/gollvm/gofrontend/go/gogo.cc:8249
#10 0x00005555557fb328 in Gogo::write_globals (this=0x55555997b460) at /s/llvm/tools/gollvm/gofrontend/go/gogo.cc:1585
#11 0x00005555557f39e9 in go_write_globals () at /s/llvm/tools/gollvm/gofrontend/go/go.cc:185
#12 0x00005555557e162d in gollvm::driver::CompileGoImpl::invokeFrontEnd (this=0x55555996c190) at /s/llvm/tools/gollvm/driver/CompileGo.cpp:798
#13 0x00005555557de88d in gollvm::driver::CompileGoImpl::performAction (this=0x55555996c190, compilation=..., jobAction=..., inputArtifacts=..., output=...) at /s/llvm/tools/gollvm/driver/CompileGo.cpp:191
#14 0x00005555557e2334 in gollvm::driver::CompileGo::performAction (this=0x55555996b9d0, compilation=..., jobAction=..., inputArtifacts=..., output=...) at /s/llvm/tools/gollvm/driver/CompileGo.cpp:1004
#15 0x00005555557d3620 in gollvm::driver::Driver::processAction (this=0x7fffffffd650, act=0x55555996b690, compilation=..., lastAct=false) at /s/llvm/tools/gollvm/driver/Driver.cpp:546
#16 0x00005555557d37a8 in gollvm::driver::Driver::processActions (this=0x7fffffffd650, compilation=...) at /s/llvm/tools/gollvm/driver/Driver.cpp:568
#17 0x00005555557c8cc4 in main (argc=16, argv=0x7fffffffda48) at /s/llvm/tools/gollvm/driver-main/llvm-goc.cpp:213

This seems to compile without crashing in gccgo, but in gollvm we hit an assert.

Need to look more, but it appears that this is related to inline function bodies in export data. If I change the definition of Apply() in novarmethod,go to

func (EmptyDialOption) Apply(*dialOptions) { defer func() { QQ++ }() }

the program compiles cleanly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions