[MLIR](convert-async-to-llvm) mlir-opt triggers segmentation fault with convert-async-to-llvm
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
git version: 3ae0d109f87dedd2a3f5bdf517556ba3d44283d6
MLIR Program:
```mlir
module {
func.func @test(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>) -> !async.value> {
%0 = async.runtime.create : !async.value>
return %0 : !async.value>
}
}
```
Reproduce Command: `mlir-opt -convert-async-to-llvm a.mlir`
StackTrace:
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: mlir-opt -convert-async-to-llvm a.mlir
#0 0x0000555a964f949f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x202b49f)
#1 0x0000555a964f5c3c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2027c3c)
#2 0x0000555a964f5de3 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f2eb34ee420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x0000555a9fa9ec87 mlir::Type::getContext() const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5d0c87)
#5 0x0000555a9f9b2e0b mlir::TypeAttr::get(mlir::Type) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb4e4e0b)
#6 0x0000555a9ebc83e2 mlir::LLVM::GEPOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::Type, mlir::Type, mlir::Value, llvm::ArrayRef, mlir::LLVM::GEPNoWrapFlags, llvm::ArrayRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xa6fa3e2)
#7 0x0000555a9ebc8513 mlir::LLVM::GEPOp::create(mlir::OpBuilder&, mlir::Location, mlir::Type, mlir::Type, mlir::Value, llvm::ArrayRef, mlir::LLVM::GEPNoWrapFlags, llvm::ArrayRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xa6fa513)
#8 0x0000555a9801f5df (anonymous namespace)::RuntimeCreateOpLowering::matchAndRewrite(mlir::async::RuntimeCreateOp, mlir::async::RuntimeCreateOpAdaptor, mlir::ConversionPatternRewriter&) const AsyncToLLVM.cpp:0:0
#9 0x0000555a9802ca17 llvm::LogicalResult mlir::ConversionPattern::dispatchTo1To1, mlir::async::RuntimeCreateOp>(mlir::ConvertOpToLLVMPattern const&, mlir::async::RuntimeCreateOp, mlir::async::RuntimeCreateOp::GenericAdaptor>, mlir::ConversionPatternRewriter&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x3b5ea17)
#10 0x0000555a9802cb09 mlir::ConvertOpToLLVMPattern::matchAndRewrite(mlir::Operation*, llvm::ArrayRef, mlir::ConversionPatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x3b5eb09)
#11 0x0000555a9f6402b8 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb1722b8)
#12 0x0000555a9f687662 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#13 0x0000555a9f688bc8 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb1babc8)
#14 0x0000555a9f63af8b (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#15 0x0000555a9f63b476 mlir::OperationConverter::convert(mlir::Operation*, bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb16d476)
#16 0x0000555a9f6462ba mlir::OperationConverter::applyConversion(llvm::ArrayRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb1782ba)
#17 0x0000555a9f647b58 applyConversion(llvm::ArrayRef, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#18 0x0000555a9f647d36 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb179d36)
#19 0x0000555a980274d7 (anonymous namespace)::ConvertAsyncToLLVMPass::runOnOperation() AsyncToLLVM.cpp:0:0
#20 0x0000555a9f6f3201 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb225201)
#21 0x0000555a9f6f3590 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb225590)
#22 0x0000555a9f6f5644 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb227644)
#23 0x0000555a9f6f66c1 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb2286c1)
#24 0x0000555a965bf9bb performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#25 0x0000555a965c04ff processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#26 0x0000555a965c072b llvm::LogicalResult llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr>, llvm::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#27 0x0000555a9fac4525 mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5f6525)
#28 0x0000555a965b6774 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#29 0x0000555a965c0c47 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20f2c47)
#30 0x0000555a965c0e83 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20f2e83)
#31 0x0000555a9643dbb7 main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1f6fbb7)
#32 0x00007f2eb2fba083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#33 0x0000555a964d5a6e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2007a6e)
Segmentation fault (core dumped)
```
Contributor guide
Research direction
Run the supplied mlir-opt command with the reproducer first. Then inspect AsyncToLLVM.cpp, especially RuntimeCreateOpLowering::matchAndRewrite and the LLVM::GEPOp::build call shown in the stack trace. Done means this input no longer causes a segmentation fault during convert-async-to-llvm.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100