<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/151454>151454</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]`mlir-runner` crashes when calling `printMemrefI32`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
sweead
</td>
</tr>
</table>
<pre>
test commit: [d1e43f6](https://github.com/llvm/llvm-project/commit/d1e43f6c1a28c3c64b3655be1fc1aff1029c48c8)
step to reproduce:
```
mlir-runner test.mlir -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so
```
Minimal MLIR program (test.mlir):
```
module {
llvm.func @malloc(i64) -> !llvm.ptr
llvm.func @printMemrefI32(i64, !llvm.ptr) attributes {sym_visibility = "private"}
llvm.func @main() {
%0 = llvm.mlir.constant(1 : index) : i64
%1 = llvm.alloca %0 x !llvm.struct<(ptr, ptr, i64)> : (i64) -> !llvm.ptr
%2 = llvm.mlir.poison : !llvm.struct<(i64, ptr)>
%3 = llvm.insertvalue %0, %2[0] : !llvm.struct<(i64, ptr)>
%4 = llvm.insertvalue %1, %3[1] : !llvm.struct<(i64, ptr)>
%5 = llvm.extractvalue %4[0] : !llvm.struct<(i64, ptr)>
%6 = llvm.extractvalue %4[1] : !llvm.struct<(i64, ptr)>
llvm.call @printMemrefI32(%5, %6) : (i64, !llvm.ptr) -> ()
llvm.return
}
}
```
Crash backtrace:
```
Unranked Memref base@ = 0x616d5f72696c6d5f rank = 1 offset = 140734854360681 sizes = [139904937754669] strides = [40] data =
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/workdir/llvm-project/build/bin/mlir-runner test.mlir -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so
#0 0x000056212b955f38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/workdir/llvm-project/build/bin/mlir-runner+0x434f38)
#1 0x000056212b953835 llvm::sys::RunSignalHandlers() (/home/workdir/llvm-project/build/bin/mlir-runner+0x432835)
#2 0x000056212b956ce1 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f3e27b9c520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f3e2634a1c7 impl::MemRefDataPrinter<int>::print(std::ostream&, int*, long, long, long, long const*, long const*) (/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so+0x81c7)
#5 0x00007f3e2634a1b2 impl::MemRefDataPrinter<int>::print(std::ostream&, int*, long, long, long, long const*, long const*) (/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so+0x81b2)
#6 0x00007f3e2634a0e6 void impl::printMemRef<int>(DynamicMemRefType<int> const&) (/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so+0x80e6)
#7 0x00007f3e26347e0e printMemrefI32 (/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so+0x5e0e)
#8 0x00007f3e281e0018
#9 0x00007f3e281e002d
#10 0x000056212be57226 compileAndExecute((anonymous namespace)::Options&, mlir::Operation*, llvm::StringRef, (anonymous namespace)::CompileAndExecuteConfig, void**, std::unique_ptr<llvm::TargetMachine, std::default_delete<llvm::TargetMachine>>) JitRunner.cpp:0:0
#11 0x000056212be54d3d compileAndExecuteVoidFunction((anonymous namespace)::Options&, mlir::Operation*, llvm::StringRef, (anonymous namespace)::CompileAndExecuteConfig, std::unique_ptr<llvm::TargetMachine, std::default_delete<llvm::TargetMachine>>) JitRunner.cpp:0:0
#12 0x000056212be53046 mlir::JitRunnerMain(int, char**, mlir::DialectRegistry const&, mlir::JitRunnerConfig) (/home/workdir/llvm-project/build/bin/mlir-runner+0x932046)
#13 0x000056212b7584d7 main (/home/workdir/llvm-project/build/bin/mlir-runner+0x2374d7)
#14 0x00007f3e27b83d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#15 0x00007f3e27b83e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#16 0x000056212b757fb5 _start (/home/workdir/llvm-project/build/bin/mlir-runner+0x236fb5)
Segmentation fault (core dumped)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzcWFFv27AR_jX0C2GDIkVKevCDY8dYhwYrkm6vBkWdbK4S5ZFUmuzXD6TkyHbSoO0yoFjR2BbJu_u-j8cjKemc3huAJeI3iG9msveHzi7ddwBZzcquel56cB6rrm21R2yFEb-pEkhZLRDfIJofvD86xFaIbhHd7rU_9OVCdS2i26Z5PH3Nj7b7JyiP6HZ0RbejG5VImiumRFoywXkJSa0SWdcJoYVKc5UjWiCyQmTlPByx77CFo-2qXkEIS1ZIkPE_WbWNtnPbGwMWB-CL0IDngFupDZ6D8fZ5fuy08XMLrm88YpvHTld47g7SQjVvdOkQ2yC6PXQtILr93tlvlbaveZS9bqrQrMvhM4TaDbF3vdeNW7juCh4iqzttdCsbfPf50z0-2m5vZYsRzV_QBrqveXVV3wBG2Q0iK4wDlEXdG4VRSlrZNJ1CNNciRbTAc8RuMaJJHHT09rXF0Wrj76C1UH9i9GS5vjCiBZbeW132HlwI7J7b3aN2utSN9s8YsQ1GlB6tfpQeEKUo27yFTRtEwxS-YMcYUU6ifRwaOC9UZ5yXxiOaJzikmTYVPEWz8CDSyTSZTCNxOfh7ekHvvO2VR2yNaB6ZrPH4NQgU5QmZ_L5iMRi9wnnstOvMaP463KjjoB9it5MjNjnSxoH1j7LpIUIflOcU8RuC-OannePJe_pD78nonSF-k_ymdz55hydvpZrcp_8FaPG-299CGwcq2TRvpnngMuohTrn1w-wfk2IsPy_OLfjemtgyZPz4ebnK11a6Ay6l-haIvVGo_m6sNN-gwgM-XEoHKB2WBXkSiah4nVFRCBV-4TA49iW4q2sHfnhIScbSnKdMEJEn2Ol_h7UaVia_SVhRkLRgWcZTIYqgpvNWV9OINM5cJb0cWsjqy-fb1c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