Skip to content

gollvm: crash compiling call -> convert in function with defer #31388

@thanm

Description

@thanm

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

Gollvm tip

$ go version
go version go1.12.1 gollvm LLVM 9.0.0svn 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 this program with gollvm

https://play.golang.org/p/TySgdiJzL7l

What did you expect to see?

Clean compilation

What did you see instead?

Compiler crashes (depends on how it is built, BTW).

Stack trace at crash looks like:

#0 llvm::Type::getContext (...) at .../llvm/include/llvm/IR/Type.h:129 #1 llvm::Value::getContext (...) at .../llvm/lib/IR/Value.cpp:709 #2 llvm::SwitchInst::SwitchInst (...) at .../llvm/lib/IR/Instructions.cpp:3723 #3 llvm::SwitchInst::Create (...) at .../llvm/include/llvm/IR/Instructions.h:3337 #4 llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateSwitch (...) at .../llvm/include/llvm/IR/IRBuilder.h:879 #5 GenBlocks::genSwitch (...) at .../llvm/tools/gollvm/bridge/go-llvm.cpp:3205 #6 GenBlocks::walk (...) at .../llvm/tools/gollvm/bridge/go-llvm.cpp:3713 #7 GenBlocks::walk (...) at .../llvm/tools/gollvm/bridge/go-llvm.cpp:3700

What's happening here is that you have a call instruction feeding into some other node (in this case a convert) that directly inherits its llvm::Value. When the call is written an invoke, the value for the call Bexpression is changed, but not the Bexpression of the parent (in this case the convert). This result in an access to a stale/deleted value.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions