Issue 234635
Summary [MLIR][OpenMP][fuzzer-found] omp.new_cli verifier casts a non-loop-transformation user
Labels
Assignees
Reporter Kiritobl
    #### Version

git commit hash:  059577967e64f14231b35bcd57f2b88c29909afc

LLVM/MLIR 24.0.0git, optimized build with assertions.

#### Bug Description

An `omp.new_cli` result used by an ordinary `func.call` makes `mlir-opt` abort during verification. The call provides a simple user that does not implement `omp::LoopTransformationInterface`.

#### Crash Chain & Root Cause

**Crash chain:**

```text
`omp.new_cli` verification
  → `NewCliOp::verify()` iterates over result uses
  → `cast<LoopTransformationInterface>(use.getOwner())` on `func.call`
  → incompatible-type assertion
```

`NewCliOp::verify()` assumes every operation using the CLI result implements `LoopTransformationInterface` and unconditionally casts the owner of each use. A generic-form input can contain a different user, so the cast fails before the verifier can report that the CLI has an unsupported use. Checking the interface with `dyn_cast` and returning an op error would avoid the process abort.

#### Steps to Reproduce

Run the following command with the provided reproducer MLIR:

```bash
mlir-opt reproducer.mlir -o /dev/null
```

The command returns 134 (`SIGABRT`) during verification, before any pass runs. Expected behavior is a diagnostic for an unsupported CLI user.

#### Reproducer (`reproducer.mlir`)

```mlir
module {
  func.func private @sink(!omp.cli)
  func.func @f() {
    %cli = "omp.new_cli"() : () -> !omp.cli
    func.call @sink(%cli) : (!omp.cli) -> ()
    return
  }
}
```

#### Stack Dump

```text
mlir-opt: llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From*) [with To = mlir::omp::LoopTransformationInterface; >From = mlir::Operation]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' 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: mlir-opt reproducer.mlir -o /dev/null
 #0 0x000055a7ad05a669 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (mlir-opt+0x1f9b669)
 #1 0x000055a7ad056e6c llvm::sys::RunSignalHandlers() (mlir-opt+0x1f97e6c)
 #2 0x000055a7ad056fd6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f0f08711520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f0f087659bc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f0f087659bc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f0f087659bc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f0f08711476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f0f086f77f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f0f086f771b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f0f08708e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x000055a7b471bd6f mlir::omp::NewCliOp::verify() (mlir-opt+0x965cd6f)
#12 0x000055a7b471c605 mlir::RegisteredOperationName::Model<mlir::omp::NewCliOp>::verifyInvariants(mlir::Operation*) (mlir-opt+0x965d605)
#13 0x000055a7b59f5a28 (anonymous namespace)::OperationVerifier::verifyOnEntrance(mlir::Operation&) Verifier.cpp:0:0
#14 0x000055a7b59f7cfe (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#15 0x000055a7b59f843d (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#16 0x000055a7b59f843d (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#17 0x000055a7b59f95ff mlir::verify(mlir::Operation*, bool) (mlir-opt+0xa93a5ff)
#18 0x000055a7b5308c32 mlir::parseAsmSourceFile(llvm::SourceMgr const&, mlir::Block*, mlir::ParserConfig const&, mlir::AsmParserState*, mlir::AsmParserCodeCompleteContext*) (mlir-opt+0xa249c32)
#19 0x000055a7ad121a71 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#20 0x000055a7ad1233de processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#21 0x000055a7ad123621 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#22 0x000055a7b5a13acd mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (mlir-opt+0xa954acd)
#23 0x000055a7ad11e3da mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#24 0x000055a7ad123bf8 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (mlir-opt+0x2064bf8)
#25 0x000055a7ad123e54 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (mlir-opt+0x2064e54)
#26 0x000055a7acff4d47 main (mlir-opt+0x1f35d47)
#27 0x00007f0f086f8d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#28 0x00007f0f086f8e40 call_init ./csu/../csu/libc-start.c:128:20
#29 0x00007f0f086f8e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#30 0x000055a7ad039f05 _start (mlir-opt+0x1f7af05)
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to