<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/128307>128307</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]`-test-bytecode-roundtrip` triggers Assertion Failure `succeeded(versionOr) && "expected reader to be able to access " "the version for test dialect"'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
xisang0
</td>
</tr>
</table>
<pre>
Test on commit: https://github.com/llvm/llvm-project/commit/47928ab16b675c17826ada16f23aa0569e93a474
steps to reproduce:
```
mlir-opt test.mlir -test-bytecode-roundtrip
```
test case:
```
module {
func.func @gather_like(%arg0 : tensor<?x?xf32> {bufferization.writable = false},%arg1 : tensor<?xi32> {bufferization.writable = false},%arg2 : tensor<?x?xf32> {bufferization.writable = true}) -> ()
{
%0 = linalg.generic {
indexing_maps = [affine_map<(d0, d1) -> (d0)>,affine_map<(d0, d1) -> (d0, d1)>],
iterator_types = ["parallel", "parallel"]}
ins(%arg1 : tensor<?xi32>) outs(%arg2 : tensor<?x?xf32>) {
^bb0(%arg3: i32, %arg4 : f32):
%iv1 = linalg.index 1 : index
%1 = arith.index_cast %arg3 : i32 to index
%2 = tensor.extract %arg0[%1, %iv1] : tensor<?x?xf32>
linalg.yield %2 : f32
} -> tensor<?x?xf32>
return
}
}
```
crash trace:
```
mlir-opt: /home/workdir/llvm-project-19/mlir/test/lib/IR/TestBytecodeRoundtrip.cpp:170: auto (anonymous namespace)::TestBytecodeRoundtripPass::runTest0(Operation *)::(anonymous class)::operator()(DialectBytecodeReader &, StringRef, Type &) const: Assertion `succeeded(versionOr) && "expected reader to be able to access " "the version for test dialect"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ./mlir-opt /home/workdir/test.mlir -test-bytecode-roundtrip
#0 0x00005b9273c129b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x107f9b8)
#1 0x00005b9273c104de llvm::sys::RunSignalHandlers() (./mlir-opt+0x107d4de)
#2 0x00005b9273c133c8 SignalHandler(int) Signals.cpp:0:0
#3 0x00007a45e805a520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007a45e80ae9fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007a45e805a476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007a45e80407f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007a45e804071b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007a45e8051e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00005b9276d9b0f4 (./mlir-opt+0x42080f4)
#10 0x00005b9278f87e01 (anonymous namespace)::AttrTypeReader::resolveType(unsigned long) BytecodeReader.cpp:0:0
#11 0x00005b9278f86ad7 (anonymous namespace)::DialectReader::readType(mlir::Type&) BytecodeReader.cpp:0:0
#12 0x00005b9276ff0900 (anonymous namespace)::BuiltinDialectBytecodeInterface::readAttribute(mlir::DialectBytecodeReader&) const BuiltinDialectBytecode.cpp:0:0
#13 0x00005b9278f876a4 (anonymous namespace)::AttrTypeReader::resolveAttribute(unsigned long) BytecodeReader.cpp:0:0
#14 0x00005b9278f86a37 (anonymous namespace)::DialectReader::readAttribute(mlir::Attribute&) BytecodeReader.cpp:0:0
#15 0x00005b9276ff069c (anonymous namespace)::BuiltinDialectBytecodeInterface::readAttribute(mlir::DialectBytecodeReader&) const BuiltinDialectBytecode.cpp:0:0
#16 0x00005b9278f876a4 (anonymous namespace)::AttrTypeReader::resolveAttribute(unsigned long) BytecodeReader.cpp:0:0
#17 0x00005b9278f86a37 (anonymous namespace)::DialectReader::readAttribute(mlir::Attribute&) BytecodeReader.cpp:0:0
#18 0x00005b9276ff3374 llvm::LogicalResult mlir::DialectBytecodeReader::readList<mlir::Attribute, llvm::LogicalResult mlir::DialectBytecodeReader::readAttributes<mlir::Attribute>(llvm::SmallVectorImpl<mlir::Attribute>&)::'lambda'(mlir::Attribute&)>(llvm::SmallVectorImpl<mlir::Attribute>&, llvm::LogicalResult mlir::DialectBytecodeReader::readAttributes<mlir::Attribute>(llvm::SmallVectorImpl<mlir::Attribute>&)::'lambda'(mlir::Attribute&)&&) (./mlir-opt+0x4460374)
#19 0x00005b9276ff0536 (anonymous namespace)::BuiltinDialectBytecodeInterface::readAttribute(mlir::DialectBytecodeReader&) const BuiltinDialectBytecode.cpp:0:0
#20 0x00005b9278f876a4 (anonymous namespace)::AttrTypeReader::resolveAttribute(unsigned long) BytecodeReader.cpp:0:0
#21 0x00005b9278f86a92 (anonymous namespace)::DialectReader::readOptionalAttribute(mlir::Attribute&) BytecodeReader.cpp:0:0
#22 0x00005b92740a5276 llvm::LogicalResult mlir::DialectBytecodeReader::readOptionalAttribute<mlir::ArrayAttr>(mlir::ArrayAttr&) (./mlir-opt+0x1512276)
#23 0x00005b92742a34e7 mlir::func::FuncOp::readProperties(mlir::DialectBytecodeReader&, mlir::OperationState&) (./mlir-opt+0x17104e7)
#24 0x00005b9278f84388 mlir::BytecodeReader::Impl::parseRegions(std::vector<mlir::BytecodeReader::Impl::RegionReadState, std::allocator<mlir::BytecodeReader::Impl::RegionReadState>>&, mlir::BytecodeReader::Impl::RegionReadState&) (./mlir-opt+0x63f1388)
#25 0x00005b9278f7fd9b mlir::BytecodeReader::Impl::parseIRSection(llvm::ArrayRef<unsigned char>, mlir::Block*) (./mlir-opt+0x63ecd9b)
#26 0x00005b9278f7d1fd mlir::BytecodeReader::Impl::read(mlir::Block*, llvm::function_ref<bool (mlir::Operation*)>) (./mlir-opt+0x63ea1fd)
#27 0x00005b9278f85b7e readBytecodeFileImpl(llvm::MemoryBufferRef, mlir::Block*, mlir::ParserConfig const&, std::shared_ptr<llvm::SourceMgr> const&) BytecodeReader.cpp:0:0
#28 0x00005b9278f85a0e mlir::readBytecodeFile(llvm::MemoryBufferRef, mlir::Block*, mlir::ParserConfig const&) (./mlir-opt+0x63f2a0e)
#29 0x00005b9276ec8fbf mlir::parseSourceFile(llvm::SourceMgr const&, mlir::Block*, mlir::ParserConfig const&, mlir::LocationAttr*) (./mlir-opt+0x4335fbf)
#30 0x00005b9276ec9658 mlir::parseSourceString(llvm::StringRef, mlir::Block*, mlir::ParserConfig const&, llvm::StringRef, mlir::LocationAttr*) (./mlir-opt+0x4336658)
#31 0x00005b9276d9ab44 (anonymous namespace)::TestBytecodeRoundtripPass::doRoundtripWithConfigs(mlir::Operation*, mlir::BytecodeWriterConfig const&, mlir::ParserConfig const&) TestBytecodeRoundtrip.cpp:0:0
#32 0x00005b9276d986d0 (anonymous namespace)::TestBytecodeRoundtripPass::runOnOperation() TestBytecodeRoundtrip.cpp:0:0
#33 0x00005b9276ecc08f mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x433908f)
#34 0x00005b9276ecc872 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x4339872)
#35 0x00005b9276ecf01e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x433c01e)
#36 0x00005b9276ec7b3b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#37 0x00005b9276ec779b llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, 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&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#38 0x00005b9276f71f25 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::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (./mlir-opt+0x43def25)
#39 0x00005b9276ec2682 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x432f682)
#40 0x00005b9276ec2933 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x432f933)
#41 0x00005b9276ec2b42 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x432fb42)
#42 0x00005b9273bf1bd7 main (./mlir-opt+0x105ebd7)
#43 0x00007a45e8041d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#44 0x00007a45e8041e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#45 0x00005b9273bf1745 _start (./mlir-opt+0x105e745)
Aborted (core dumped)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzcWltT4zgW_jXiRUVKlu8PPIRLaqnqLijo2nlMydZx0OJYXklmYH_9lmQnvhAHQu_sTM_U0ARZOuc796MTM63FpgK4QOElCq_PWGOepLp4FZpVG3KWSf528QO0wbLCudxuhUH-Ej8ZU2vkLxFdIbraCPPUZItcbhFdleXL7td5reS_IDeIrrqjdBXEKU1Y5kVZFIe5Fyc0Ypx5UUF9xkgYpZD6LIgDRJbaQK2xkVhBrSRvcrAcyRJFpPufL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