Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM report: Invalid pointer #56

Closed
specialpointcentral opened this issue Dec 28, 2023 · 3 comments · Fixed by #57
Closed

LLVM report: Invalid pointer #56

specialpointcentral opened this issue Dec 28, 2023 · 3 comments · Fixed by #57

Comments

@specialpointcentral
Copy link

While I running basic tests, I discovered that LLVM encounters an invalid pointer error.
Could you please give a some advice on how to fix this?

Thanks.

> ./build/bin/heco < test/example.mlir
realloc(): invalid pointer
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./build/bin/heco
1.      MLIR Parser: custom op parser 'builtin.module'
2.      MLIR Parser: custom op parser 'func.func'
3.      MLIR Parser: custom op parser 'affine.for'
4.      MLIR Parser: custom op parser 'fhe.sub'
 #0 0x000055754d51a6ed llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/x/fun/HECO/dependencies/llvm-project/llvm/lib/Support/Unix/Signals.inc:602:11
 #1 0x000055754d51ac8b PrintStackTraceSignalHandler(void*) /home/x/fun/HECO/dependencies/llvm-project/llvm/lib/Support/Unix/Signals.inc:675:1
 #2 0x000055754d518b53 llvm::sys::RunSignalHandlers() /home/x/fun/HECO/dependencies/llvm-project/llvm/lib/Support/Signals.cpp:104:5
 #3 0x000055754d51b521 SignalHandler(int) /home/x/fun/HECO/dependencies/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x00007fae16fc5710 (/usr/lib/libc.so.6+0x3e710)
 #5 0x00007fae1701583c (/usr/lib/libc.so.6+0x8e83c)
 #6 0x00007fae16fc5668 gsignal (/usr/lib/libc.so.6+0x3e668)
 #7 0x00007fae16fad4b8 abort (/usr/lib/libc.so.6+0x264b8)
 #8 0x00007fae16fae390 (/usr/lib/libc.so.6+0x27390)
 #9 0x00007fae1701f7b7 (/usr/lib/libc.so.6+0x987b7)
#10 0x00007fae1702491c __libc_realloc (/usr/lib/libc.so.6+0x9d91c)
#11 0x000055754d46478d llvm::safe_realloc(void*, unsigned long) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/Support/MemAlloc.h:53:9
#12 0x000055754d465012 llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) /home/x/fun/HECO/dependencies/llvm-project/llvm/lib/Support/SmallVector.cpp:151:13
#13 0x0000557545abb295 llvm::SmallVectorTemplateCommon<mlir::Type, void>::grow_pod(unsigned long, unsigned long) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/SmallVector.h:142:3
#14 0x0000557545abb252 llvm::SmallVectorTemplateBase<mlir::Type, true>::grow(unsigned long) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/SmallVector.h:529:71
#15 0x0000557545ad264c mlir::Type const* llvm::SmallVectorTemplateCommon<mlir::Type, void>::reserveForParamAndGetAddressImpl<llvm::SmallVectorTemplateBase<mlir::Type, true>>(llvm::SmallVectorTemplateBase<mlir::Type, true>*, mlir::Type const&, unsigned long) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/SmallVector.h:247:12
#16 0x0000557545ad25d5 llvm::SmallVectorTemplateBase<mlir::Type, true>::reserveForParamAndGetAddress(mlir::Type&, unsigned long) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/SmallVector.h:540:5
#17 0x0000557545aa32d3 llvm::SmallVectorTemplateBase<mlir::Type, true>::push_back(mlir::Type) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/SmallVector.h:566:23
#18 0x0000557545ace30f mlir::Type& llvm::SmallVectorTemplateBase<mlir::Type, true>::growAndEmplaceBack<>() /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/SmallVector.h:560:5
#19 0x0000557545ace26f mlir::Type& llvm::SmallVectorImpl<mlir::Type>::emplace_back<>() /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/SmallVector.h:943:7
#20 0x0000557545ace210 mlir::AsmParser::parseTypeList(llvm::SmallVectorImpl<mlir::Type>&)::'lambda'()::operator()() const /home/x/fun/HECO/dependencies/llvm-project/mlir/include/mlir/IR/OpImplementation.h:1183:41
#21 0x0000557545ace1d5 mlir::ParseResult llvm::function_ref<mlir::ParseResult ()>::callback_fn<mlir::AsmParser::parseTypeList(llvm::SmallVectorImpl<mlir::Type>&)::'lambda'()>(long) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#22 0x000055754a6ebea9 llvm::function_ref<mlir::ParseResult ()>::operator()() const /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#23 0x000055754a6d56e8 mlir::detail::Parser::parseCommaSeparatedList(mlir::AsmParser::Delimiter, llvm::function_ref<mlir::ParseResult ()>, llvm::StringRef) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:105:7
#24 0x000055754a6f140c mlir::detail::AsmParserImpl<mlir::OpAsmParser>::parseCommaSeparatedList(mlir::AsmParser::Delimiter, llvm::function_ref<mlir::ParseResult ()>, llvm::StringRef) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/AsmParserImpl.h:315:19
#25 0x0000557549e27d81 heco::fhe::AddOp::parse(mlir::OpAsmParser&, mlir::OperationState&) (./build/bin/heco+0x4741d81)
#26 0x0000557545adbd8d mlir::ParseResult llvm::detail::UniqueFunctionBase<mlir::ParseResult, mlir::OpAsmParser&, mlir::OperationState&>::CallImpl<mlir::ParseResult (*)(mlir::OpAsmParser&, mlir::OperationState&)>(void*, mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:220:12
#27 0x000055754a098c2f llvm::unique_function<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::operator()(mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:382:12
#28 0x000055754a6ef9f5 mlir::ParseResult llvm::function_ref<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::callback_fn<llvm::unique_function<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>>(long, mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#29 0x000055754a0e3cc9 llvm::function_ref<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::operator()(mlir::OpAsmParser&, mlir::OperationState&) const /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#30 0x000055754a6ddc97 (anonymous namespace)::CustomOpAsmParser::parseOperation(mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1491:9
#31 0x000055754a6dc245 (anonymous namespace)::OperationParser::parseCustomOperation(llvm::ArrayRef<std::tuple<llvm::StringRef, unsigned int, llvm::SMLoc>>) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1987:19
#32 0x000055754a6d81b0 (anonymous namespace)::OperationParser::parseOperation() /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1146:8
#33 0x000055754a6e71a6 (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2263:9
#34 0x000055754a6e5f91 (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2193:12
#35 0x000055754a6e5aab (anonymous namespace)::OperationParser::parseRegionBody(mlir::Region&, llvm::SMLoc, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2151:7
#36 0x000055754a6e2723 (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2088:7
#37 0x000055754a6dfd52 (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1755:16
#38 0x0000557545a4b657 mlir::affine::AffineForOp::parse(mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/Dialect/Affine/IR/AffineOps.cpp:2142:14
#39 0x0000557545adbd8d mlir::ParseResult llvm::detail::UniqueFunctionBase<mlir::ParseResult, mlir::OpAsmParser&, mlir::OperationState&>::CallImpl<mlir::ParseResult (*)(mlir::OpAsmParser&, mlir::OperationState&)>(void*, mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:220:12
#40 0x000055754a098c2f llvm::unique_function<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::operator()(mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:382:12
#41 0x000055754a6ef9f5 mlir::ParseResult llvm::function_ref<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::callback_fn<llvm::unique_function<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>>(long, mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#42 0x000055754a0e3cc9 llvm::function_ref<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::operator()(mlir::OpAsmParser&, mlir::OperationState&) const /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#43 0x000055754a6ddc97 (anonymous namespace)::CustomOpAsmParser::parseOperation(mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1491:9
#44 0x000055754a6dc245 (anonymous namespace)::OperationParser::parseCustomOperation(llvm::ArrayRef<std::tuple<llvm::StringRef, unsigned int, llvm::SMLoc>>) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1987:19
#45 0x000055754a6d81b0 (anonymous namespace)::OperationParser::parseOperation() /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1146:8
#46 0x000055754a6e71a6 (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2263:9
#47 0x000055754a6e5f91 (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2193:12
#48 0x000055754a6e5aab (anonymous namespace)::OperationParser::parseRegionBody(mlir::Region&, llvm::SMLoc, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2151:7
#49 0x000055754a6e2723 (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2088:7
#50 0x000055754a6dfd52 (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1755:16
#51 0x000055754a6dfe6b (anonymous namespace)::CustomOpAsmParser::parseOptionalRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1766:12
#52 0x000055754a09a311 mlir::function_interface_impl::parseFunctionOp(mlir::OpAsmParser&, mlir::OperationState&, bool, mlir::StringAttr, llvm::function_ref<mlir::Type (mlir::Builder&, llvm::ArrayRef<mlir::Type>, llvm::ArrayRef<mlir::Type>, mlir::function_interface_impl::VariadicFlag, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)>, mlir::StringAttr, mlir::StringAttr) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/IR/FunctionImplementation.cpp:232:14
#53 0x00005575463db60c mlir::func::FuncOp::parse(mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/Dialect/Func/IR/FuncOps.cpp:199:10
#54 0x0000557545adbd8d mlir::ParseResult llvm::detail::UniqueFunctionBase<mlir::ParseResult, mlir::OpAsmParser&, mlir::OperationState&>::CallImpl<mlir::ParseResult (*)(mlir::OpAsmParser&, mlir::OperationState&)>(void*, mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:220:12
#55 0x000055754a098c2f llvm::unique_function<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::operator()(mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:382:12
#56 0x000055754a6ef9f5 mlir::ParseResult llvm::function_ref<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::callback_fn<llvm::unique_function<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>>(long, mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#57 0x000055754a0e3cc9 llvm::function_ref<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::operator()(mlir::OpAsmParser&, mlir::OperationState&) const /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#58 0x000055754a6ddc97 (anonymous namespace)::CustomOpAsmParser::parseOperation(mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1491:9
#59 0x000055754a6dc245 (anonymous namespace)::OperationParser::parseCustomOperation(llvm::ArrayRef<std::tuple<llvm::StringRef, unsigned int, llvm::SMLoc>>) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1987:19
#60 0x000055754a6d81b0 (anonymous namespace)::OperationParser::parseOperation() /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1146:8
#61 0x000055754a6e71a6 (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2263:9
#62 0x000055754a6e5f91 (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2193:12
#63 0x000055754a6e5aab (anonymous namespace)::OperationParser::parseRegionBody(mlir::Region&, llvm::SMLoc, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2151:7
#64 0x000055754a6e2723 (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2088:7
#65 0x000055754a6dfd52 (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1755:16
#66 0x0000557549ff4bea mlir::ModuleOp::parse(mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/build/tools/mlir/include/mlir/IR/BuiltinOps.cpp.inc:383:14
#67 0x0000557545adbd8d mlir::ParseResult llvm::detail::UniqueFunctionBase<mlir::ParseResult, mlir::OpAsmParser&, mlir::OperationState&>::CallImpl<mlir::ParseResult (*)(mlir::OpAsmParser&, mlir::OperationState&)>(void*, mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:220:12
#68 0x000055754a098c2f llvm::unique_function<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::operator()(mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:382:12
#69 0x000055754a6ef9f5 mlir::ParseResult llvm::function_ref<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::callback_fn<llvm::unique_function<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>>(long, mlir::OpAsmParser&, mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#70 0x000055754a0e3cc9 llvm::function_ref<mlir::ParseResult (mlir::OpAsmParser&, mlir::OperationState&)>::operator()(mlir::OpAsmParser&, mlir::OperationState&) const /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#71 0x000055754a6ddc97 (anonymous namespace)::CustomOpAsmParser::parseOperation(mlir::OperationState&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1491:9
#72 0x000055754a6dc245 (anonymous namespace)::OperationParser::parseCustomOperation(llvm::ArrayRef<std::tuple<llvm::StringRef, unsigned int, llvm::SMLoc>>) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1987:19
#73 0x000055754a6d81b0 (anonymous namespace)::OperationParser::parseOperation() /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:1146:8
#74 0x000055754a6d7b18 (anonymous namespace)::TopLevelOperationParser::parse(mlir::Block*, mlir::Location) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2684:20
#75 0x000055754a6d7957 mlir::parseAsmSourceFile(llvm::SourceMgr const&, mlir::Block*, mlir::ParserConfig const&, mlir::AsmParserState*, mlir::AsmParserCodeCompleteContext*) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/AsmParser/Parser.cpp:2744:41
#76 0x000055754a12fe44 mlir::parseSourceFile(std::shared_ptr<llvm::SourceMgr> const&, mlir::Block*, mlir::ParserConfig const&, mlir::LocationAttr*) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/Parser/Parser.cpp:46:10
#77 0x0000557549e1a96c mlir::OwningOpRef<mlir::ModuleOp> mlir::detail::parseSourceFile<mlir::ModuleOp, std::shared_ptr<llvm::SourceMgr> const&>(mlir::ParserConfig const&, std::shared_ptr<llvm::SourceMgr> const&) /home/x/fun/HECO/dependencies/llvm-project/mlir/include/mlir/Parser/Parser.h:159:14
#78 0x0000557549e1a848 mlir::OwningOpRef<mlir::ModuleOp> mlir::parseSourceFile<mlir::ModuleOp>(std::shared_ptr<llvm::SourceMgr> const&, mlir::ParserConfig const&) /home/x/fun/HECO/dependencies/llvm-project/mlir/include/mlir/Parser/Parser.h:189:10
#79 0x0000557549e19e6e mlir::parseSourceFileForTool(std::shared_ptr<llvm::SourceMgr> const&, mlir::ParserConfig const&, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/include/mlir/Tools/ParseUtilities.h:31:12
#80 0x0000557549e0e6f7 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:353:16
#81 0x0000557549e0e4d6 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:431:12
#82 0x0000557549e0e229 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:472:12
#83 0x0000557549e0e193 mlir::LogicalResult llvm::function_ref<mlir::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&) /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#84 0x000055754cfa59ef llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/x/fun/HECO/dependencies/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#85 0x000055754cfa4ed8 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/Support/ToolUtilities.cpp:28:12
#86 0x0000557549e0af76 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:475:10
#87 0x0000557549e0b4da mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /home/x/fun/HECO/dependencies/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:531:14
#88 0x00005575459e4f3b main (./build/bin/heco+0x2fef3b)
#89 0x00007fae16faecd0 (/usr/lib/libc.so.6+0x27cd0)
#90 0x00007fae16faed8a __libc_start_main (/usr/lib/libc.so.6+0x27d8a)
#91 0x0000557545a295e5 _start (./build/bin/heco+0x3435e5)
[1]    205705 IOT instruction (core dumped)  ./build/bin/heco < test/example.mlir

I ran this code in ubuntu 22.04 and followed the instructions in https://secartifacts.github.io/usenixsec2023/appendix-files/sec23winterae-final39.pdf.

@specialpointcentral
Copy link
Author

specialpointcentral commented Jan 2, 2024

After double checking, I found out that this problem occurs if I compile using the release method.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DMLIR_DIR=dependencies/llvm-project/build/lib/cmake/mlir

If I switch to the debug way of compiling, it runs (using example.mlir).
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DMLIR_DIR=dependencies/llvm-project/build/lib/cmake/mlir

@specialpointcentral
Copy link
Author

Locating the problem, due to defects of llvm and mlir, the project could not be compiled using gcc. The related issue can be found in: llvm/llvm-project#62918

So is it possible to add the following to cmake to ensure that the problem does not occur again:

SET(CMAKE_C_COMPILER   "clang")
SET(CMAKE_CXX_COMPILER "clang++")

@AlexanderViand-Intel
Copy link
Collaborator

Thanks for reporting this! I'll have a look and see if this can be fixed by depending on a more revent version of LLVM/MLIR, or if we do indeed need to force clang as the toolchain!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants