llvm / llvm/llvm-project

[mlir] Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.

Open
#205,284 2 comments 0 reactions 0 assignees View on GitHub
crash mlir
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

git version: 5492d06d4fb99795b3b7247be374cdcb47f5ac03

system: `Ubuntu 18.04.6 LTS`

reproduce with: `mlir-opt -convert-openmp-to-llvm -convert-vector-to-llvm -acc-implicit-data a.mlir`

a.mlir:

```mlir
module {
func.func @test(%arg0: memref<10xf32>, %arg1: index) {
%0 = acc.create varPtr(%arg0 : memref<10xf32>) -> memref<10xf32>
acc.serial dataOperands(%0 : memref<10xf32>) {
%c0 = arith.constant 0 : index
%c0_0 = arith.constant 0 : index
%1 = arith.cmpi sge, %arg1, %c0 : index
%2 = arith.cmpi slt, %arg1, %c0 : index
%3 = arith.andi %1, %2 : i1
cf.assert %3, "ERROR: Runtime op verification failed\0A%7 = \22memref.load\22(%arg1, %arg2) : (memref<10xf32>, index) -> f32\0A^ out-of-bounds access\0ALocation: loc(\22/data/szy/MLIR/seed729/tmp.fJQ9P1y8uQ.mlir\22:2:8)"
%4 = memref.load %arg0[%arg1] : memref<10xf32>
acc.yield
}
return
}
}

```

stack trace:

```
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/llvm/include/llvm/Support/Casting.h:656: decltype(auto) llvm::dyn_cast(From *) [To = mlir::acc::CopyinOp, From = mlir::Operation]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.
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: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -convert-openmp-to-llvm -convert-vector-to-llvm -acc-implicit-data 58.mlir
#0 0x0000556dc5ca10f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20300f8)
#1 0x0000556dc5c9df91 llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x202cf91)
#2 0x0000556dc5ca2216 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007fe14dbdc420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fe14d21900b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007fe14d1f8859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007fe14d1f8729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
#7 0x00007fe14d1f8729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
#8 0x00007fe14d209fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#9 0x0000556dc7aa98bc mlir::acc::getBounds(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x3e388bc)
#10 0x0000556dc66973c4 (anonymous namespace)::fillInBoundsForUnknownDimensions(mlir::Operation*, mlir::OpBuilder&) ACCImplicitData.cpp:0:0
#11 0x0000556dc6695350 (anonymous namespace)::ACCImplicitData::runOnOperation()::$_0::operator()(mlir::Operation*) const ACCImplicitData.cpp:0:0
#12 0x0000556dc5d62ece void mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20f1ece)
#13 0x0000556dc5d62ece void mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20f1ece)
#14 0x0000556dc6690595 (anonymous namespace)::ACCImplicitData::runOnOperation() ACCImplicitData.cpp:0:0
#15 0x0000556dce64c502 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9db502)
#16 0x0000556dce64d344 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9dc344)
#17 0x0000556dce65425a mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9e325a)
#18 0x0000556dce653b8f mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9e2b8f)
#19 0x0000556dc5d503d0 performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#20 0x0000556dc5d4f606 llvm::LogicalResult llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0>(long, std::unique_ptr>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#21 0x0000556dce9a08a5 mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xad2f8a5)
#22 0x0000556dc5d46666 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20d5666)
#23 0x0000556dc5d46a45 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20d5a45)
#24 0x0000556dc5d46da5 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20d5da5)
#25 0x0000556dc5c86b82 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x2015b82)
#26 0x00007fe14d1fa083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#27 0x0000556dc5c866be _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20156be)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Run the reported mlir-opt command with the supplied a.mlir reproducer and inspect the ACCImplicitData.cpp frames in the stack trace, especially fillInBoundsForUnknownDimensions and the call to mlir::acc::getBounds. Determine why the pass reaches dyn_cast with a missing value; done means the reproducer no longer aborts and the regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.