<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/117281>117281</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir] Transform dialect interpreter crashed on unregistered ops
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir,
            mlir:transform_dialect
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          kuhar
      </td>
    </tr>
</table>

<pre>
    Repro:
```mlir
// RUN: mlir-opt %s --transform-interpreter --allow-unregistered-dialect

module @named attributes { transform.with_named_sequence } {
  transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) -> () {
 "test.op_a"() : () -> ()
    transform.yield
 }
}
```

Error message:
```
mlir-opt: /home/jakub/iree/iree/third_party/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From &) [To = mlir::transform
::TransformOpInterface, 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. 
Stack dump: 
0.      Program arguments: llvm-project/bin/mlir-opt /home/jakub/iree/iree/compiler/src/iree/compiler/Codegen/Common/test/link_transform_named_sequences.
mlir --transform-interpreter --allow-unregistered-dialect 
 #0 0x0000641bfd1562be llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.i
nc:723:13 
 #1 0x0000641bfd154595 llvm::sys::RunSignalHandlers() /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/Support/Signals.cpp:106:18 
 #2 0x0000641bfd15699d SignalHandler(int) /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1 
 #3 0x00007620e1442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520) 
 #4 0x00007620e14969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 
 #5 0x00007620e14969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10 
 #6 0x00007620e14969fc pthread_kill ./nptl/pthread_kill.c:89:10 
 #7 0x00007620e1442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6 
 #8 0x00007620e14287f3 abort ./stdlib/abort.c:81:7 
 #9 0x00007620e142871b _nl_load_domain ./intl/loadmsgcat.c:1177:9 
#10 0x00007620e1439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96) 
#11 0x0000641bff2385ca mlir::detail::Interface<mlir::transform::TransformOpInterface, mlir::Operation*, mlir::transform::detail::TransformOpInterfaceInte
rfaceTraits, mlir::Op<mlir::transform::TransformOpInterface>, mlir::OpTrait::TraitBase>::Interface(mlir::Operation*) /home/jakub/iree/iree/third_party/ll
vm-project/mlir/include/mlir/Support/InterfaceSupport.h:97:5 
#12 0x0000641bff2385ca mlir::OpInterface<mlir::transform::TransformOpInterface, mlir::transform::detail::TransformOpInterfaceInterfaceTraits>::OpInterfac
e(mlir::Operation*) /home/jakub/iree/iree/third_party/llvm-project/mlir/include/mlir/IR/OpDefinition.h:2086:24 
#13 0x0000641bff2385ca mlir::transform::TransformOpInterface::TransformOpInterface(mlir::Operation*) /home/jakub/iree/build/relass/llvm-project/tools/mli
r/include/mlir/Dialect/Transform/Interfaces/TransformInterfaces.h.inc:50:97 
#14 0x0000641bff2385ca llvm::CastInfo<mlir::transform::TransformOpInterface, mlir::Operation, void>::doCast(mlir::Operation&) /home/jakub/iree/iree/third
_party/llvm-project/mlir/include/mlir/IR/Operation.h:1125:52 
#15 0x0000641bff2385ca decltype(auto) llvm::cast<mlir::transform::TransformOpInterface, mlir::Operation>(mlir::Operation&) /home/jakub/iree/iree/third_party/llvm-project/llvm/include/llvm/Support/Casting.h:573:10
#16 0x0000641bff2385ca applySequenceBlock(mlir::Block&, mlir::transform::FailurePropagationMode, mlir::transform::TransformState&, mlir::transform::TransformResults&) /home/jakub/iree/iree/third_party/llvm-project/mlir/lib/Dialect/Transform/IR/TransformOps.cpp:1786:30
#17 0x0000641bff23c06e mlir::transform::NamedSequenceOp::apply(mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&) /home/jakub/iree/iree/third_party/llvm-project/mlir/lib/Dialect/Transform/IR/TransformOps.cpp:0:10
#18 0x0000641bff1ea512 mlir::transform::detail::TransformOpInterfaceInterfaceTraits::Model<mlir::transform::NamedSequenceOp>::apply(mlir::transform::detail::TransformOpInterfaceInterfaceTraits::Concept const*, mlir::Operation*, mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&) /home/jakub/iree/build/relass/llvm-project/tools/mlir/include/mlir/Dialect/Transform/Interfaces/TransformInterfaces.h.inc:477:3
#19 0x0000641bff9d0303 mlir::transform::TransformState::applyTransform(mlir::transform::TransformOpInterface) /home/jakub/iree/iree/third_party/llvm-project/mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp:952:3
#20 0x0000641bff9dad61 mlir::transform::applyTransforms(mlir::Operation*, mlir::transform::TransformOpInterface, mlir::RaggedArray<llvm::PointerUnion<mlir::Operation*, mlir::Attribute, mlir::Value>> const&, mlir::transform::TransformOptions const&, bool, llvm::function_ref<void (mlir::transform::TransformState&)>, llvm::function_ref<llvm::LogicalResult (mlir::transform::TransformState&)>) /home/jakub/iree/iree/third_party/llvm-project/mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp:2018:39
#21 0x0000641bff26b828 mlir::transform::applyTransformNamedSequence(mlir::RaggedArray<llvm::PointerUnion<mlir::Operation*, mlir::Attribute, mlir::Value>>, mlir::transform::TransformOpInterface, mlir::ModuleOp, mlir::transform::TransformOptions const&) /home/jakub/iree/iree/third_party/llvm-project/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterUtils.cpp:234:10
#22 0x0000641bff2669b3 (anonymous namespace)::InterpreterPass::runOnOperation() /home/jakub/iree/iree/third_party/llvm-project/mlir/lib/Dialect/Transform/Transforms/InterpreterPass.cpp:147:16
```

I'd expect this to exit with an error but not crash.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWd1u27gSfhr6hrBBUf8XvnDsGKfA7iZI0701KImWuaFIHZJq47c_ICVbkuu4jtP2bFHE0ogaznzzzQwpEq1ZKSidg_AOhKsJacxOqvlLsyNqksliP3-itZLAXwC0AmgBItT-rzhTnQivAV7Dpy9_AX8BrXwqawMBDjWcTo0iQm-lqqZMGKpqRQ1VcDolnMtv00YoWjJtqKLFtGCE09x0Wt3fShYNpxAESJCKFpAYo1jWGKohiO_gUfnsGzO7jRuz0fS_DRU5hSBe2VGtJjgYfDouQJvN8emmIkwAnAAcElUi6xPAXv8yEfuNrK3iXqYoKaTgexCvAE7hFPj30KlIBwYAjA3VZibrDQEYH547_cnJawebh1bvGeXFQVe86mA6XhwCM4TvXimpYEW1JiX9PoYdxl3EWkvWO1lRgNf_kJcmA3jNFKX9j9kxVWxqoswe4DXnX6tpreQ_NmrtrR0qct4UtBd8bupaKjtiSbRhopztgL8IY2xnLGjOzb6mACekMdLi4F7zF8Bf5EQbgJO1khUEOHJ4hXfPEgJ_5ZjWDjti1PnnhM8H4UP9yTJvS3IK8BK2ykbvP9RUEcOkAOHK2rTQmip7D0GEmCbAXz5L4N8DnPxNuLPCGhPZkDoT_eXzvn1uHxJVNhUVBsotZCKXVU0MyziFrZ-eC34Mt4RxWsxga_TjH_eLz_dQN1nFDCQwa0qoqMUNGgl3xtTaGutyrWRm12SzXFY9yCexYFo3VNu8JKKAXUig2VGYK6J3MCP5i1Ekp4f5PxuSv8CiqWrHAydDM-j-PSpZKlIdHbOWwJMJM5s060H2XyaSRYVxqgBea5WflS9lQUsq3FVVSXth88f6ysTLIGHH6axnPa1vqj_wmK8-gugVIYSiwMu2hRdGOKMDeuq9bi8eFRPGIfisHM2SfpAi3zZSG0VJ5VizhEyYlkMfzzXOslGCfRHs1QpYKQjXM9a6InLgL2LsA3_h-QP3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