bkryza / clang-uml

Customizable automatic UML diagram generator for C++ based on Clang.
Apache License 2.0
609 stars 43 forks source link

Bus error MacOS #210

Closed yairfine closed 11 months ago

yairfine commented 12 months ago

Hi there 👋 After fresh build on MacOS apple silicon, and running clang-uml for the first time, I'm getting a bus error I tried to (git) checkout previous releases 0.4.1 and 0.4.0 but it still occurs. The build command that worked for me is:

LLVM_VERSION=16 make release CMAKE_EXE_LINKER_FLAGS="-L/opt/homebrew/opt/llvm/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib" LLVM_DIR=/opt/homebrew/opt/llvm/lib/cmake/llvm/ CMAKE_CXX_FLAGS="-I/opt/homebrew/Cellar/yaml-cpp/0.8.0/include"

Will appreciate your advice for spotting the issue. Thanks!

bkryza commented 12 months ago

@yairfine Unfortunately I don't have Apple Silicon Mac to reproduce it, but can you paste the output of the following commands?

otool -L release/src/clang-uml

and

release/src/clang-uml --version
yairfine commented 12 months ago

@bkryza Thank you for the quick response! Here is the details you asked for:

% otool -L ./release/src/clang-uml
./release/src/clang-uml:
    /opt/homebrew/opt/yaml-cpp/lib/libyaml-cpp.0.8.dylib (compatibility version 0.8.0, current version 0.8.0)
    /opt/homebrew/opt/llvm/lib/libclang-cpp.dylib (compatibility version 0.0.0, current version 0.0.0)
    /opt/homebrew/opt/llvm/lib/libLLVM.dylib (compatibility version 1.0.0, current version 16.0.6)
    /usr/lib/libc++.1.dylib (...)
    /usr/lib/libSystem.B.dylib (...)
    /opt/homebrew/opt/llvm/lib/libunwind.1.dylib (compatibility version 1.0.0, current version 1.0.0)
% ./release/src/clang-uml --version
clang-uml 0.4.0
Copyright (C) 2021-2023 Bartek Kryza <bkryza@gmail.com>
Darwin arm64 23.0.0
Built against LLVM/Clang libraries version: 16.0.6
Using LLVM/Clang libraries version: Homebrew clang version 16.0.6
bkryza commented 12 months ago

@yairfine This looks ok to me. Can you try one more thing? Could you rebuild clang-uml in debug mode (make debug instead of make release) and rerun. Then please paste your .clang-uml config and stack trace or error printed on terminal.

Preferably on the latest master branch...

yairfine commented 12 months ago

Actually updating the CommandLineTools solved the bus error. But now after running make clanguml_diagrams, an assert is hit (latest master f3a0d98e): Assertion failed: (kind_ != template_parameter_kind_t::argument), function set_name, file template_parameter.cc, line 181. Here is the verbose log link Thank you for the help @bkryza !

bkryza commented 12 months ago

@yairfine Thanks for the logs. I've managed to reproduce it also on my old 2015 Intel MBP - I'll try to fix it...

bkryza commented 11 months ago

The stack trace for this segfault on macos (doesn't occur on Linux):

[debug] [tid 143042] [translation_unit_visitor.cc:2522] Including method YAML::convert<bool>::decode
[trace] [tid 143042] [translation_unit_visitor.cc:247] Visiting method YAML::convert<bool>::decode in class YAML::convert [0x7fc157796108]
[debug] [tid 143042] [translation_unit_visitor.cc:2436] Getting method's class with local id 25046049
[trace] [tid 143042] [translation_unit_visitor.cc:1635] Setting local element mapping 25046249 --> 100624169565391334
[trace] [tid 143042] [translation_unit_visitor.cc:275] Set id 25046249 --> 100624169565391334 for method name YAML::convert<bool>::decode(const Node &,bool &) [false]
[debug] [tid 143042] [call_expression_context.cc:148] Setting current caller id to 100624169565391334
[debug] [tid 143042] [diagram.cc:85] Adding 'method' participant: YAML::convert<bool>::decode(const Node &,bool &), 100624169565391334 [decode]
[trace] [tid 143042] [translation_unit_visitor.cc:85] Visiting class declaration at /usr/local/include/yaml-cpp/node/convert.h:230:1
[trace] [tid 143042] [translation_unit_visitor.cc:1635] Setting local element mapping 25046672 --> 1982529838695191971
[debug] [tid 143042] [translation_unit_visitor.cc:118] Adding class YAML::convert with id 1982529838695191971
[debug] [tid 143042] [call_expression_context.cc:148] Setting current caller id to 1982529838695191971
[trace] [tid 143042] [translation_unit_visitor.cc:188] Visiting template specialization declaration YAML::convert at /usr/local/include/yaml-cpp/node/convert.h:230:8
[error] [tid 143042] [template_parameter.cc:181] SETTING TEMPLATE PARAMETER NAME TO: std::map
Assertion failed: (kind_ != template_parameter_kind_t::argument), function set_name, file template_parameter.cc, line 183.
Stack trace (most recent call last) in thread 123145385979904:
#31   Object "clang-uml", at 0x101e7514c, in std::__1::__function::__alloc_func<clanguml::common::generators::generate_diagrams(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, clanguml::config::config&, std::__1::unique_ptr<clanguml::common::compilation_database, std::__1::default_delete<clanguml::common::compilation_database> > const&, clanguml::cli::runtime_config const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > > const&)::$_0, std::__1::allocator<clanguml::common::generators::generate_diagrams(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, clanguml::config::config&, std::__1::unique_ptr<clanguml::common::compilation_database, std::__1::default_delete<clanguml::common::compilation_database> > const&, clanguml::cli::runtime_config const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > > const&)::$_0>, void ()>::operator()() + 28
#30   Object "clang-uml", at 0x101e7517c, in void std::__1::__invoke_void_return_wrapper<void, true>::__call<clanguml::common::generators::generate_diagrams(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, clanguml::config::config&, std::__1::unique_ptr<clanguml::common::compilation_database, std::__1::default_delete<clanguml::common::compilation_database> > const&, clanguml::cli::runtime_config const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > > const&)::$_0&>(clanguml::common::generators::generate_diagrams(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, clanguml::config::config&, std::__1::unique_ptr<clanguml::common::compilation_database, std::__1::default_delete<clanguml::common::compilation_database> > const&, clanguml::cli::runtime_config const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > > const&)::$_0&) + 28
#29   Object "clang-uml", at 0x101e751c4, in decltype(static_cast<clanguml::common::generators::generate_diagrams(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, clanguml::config::config&, std::__1::unique_ptr<clanguml::common::compilation_database, std::__1::default_delete<clanguml::common::compilation_database> > const&, clanguml::cli::runtime_config const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > > const&)::$_0&>(fp)()) std::__1::__invoke<clanguml::common::generators::generate_diagrams(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, clanguml::config::config&, std::__1::unique_ptr<clanguml::common::compilation_database, std::__1::default_delete<clanguml::common::compilation_database> > const&, clanguml::cli::runtime_config const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > > const&)::$_0&>(clanguml::common::generators::generate_diagrams(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, clanguml::config::config&, std::__1::unique_ptr<clanguml::common::compilation_database, std::__1::default_delete<clanguml::common::compilation_database> > const&, clanguml::cli::runtime_config const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > > const&)::$_0&) + 20
#28   Object "clang-uml", at 0x101e7536a, in clanguml::common::generators::generate_diagrams(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, clanguml::config::config&, std::__1::unique_ptr<clanguml::common::compilation_database, std::__1::default_delete<clanguml::common::compilation_database> > const&, clanguml::cli::runtime_config const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > > const&)::$_0::operator()() + 394
#27   Object "clang-uml", at 0x101b5883a, in clanguml::common::generators::generate_diagram(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<clanguml::config::diagram>, clanguml::common::compilation_database const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, clanguml::cli::runtime_config const&, std::__1::function<void ()>&&) + 378
#26   Object "clang-uml", at 0x101b58fa1, in void clanguml::common::generators::detail::generate_diagram_impl<clanguml::config::sequence_diagram>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<clanguml::config::diagram>, clanguml::common::compilation_database const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, clanguml::cli::runtime_config const&, std::__1::function<void ()>&&) + 273
#25   Object "clang-uml", at 0x101cd267b, in std::__1::unique_ptr<clanguml::sequence_diagram::model::diagram, std::__1::default_delete<clanguml::sequence_diagram::model::diagram> > clanguml::common::generators::generate<clanguml::sequence_diagram::model::diagram, clanguml::config::sequence_diagram, clanguml::sequence_diagram::visitor::translation_unit_visitor>(clanguml::common::compilation_database const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, clanguml::config::sequence_diagram&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, bool, std::__1::function<void ()>) + 1643
#24   Object "libclang-cpp.dylib", at 0x112120de9, in clang::tooling::ClangTool::run(clang::tooling::ToolAction*) + 2921
#23   Object "libclang-cpp.dylib", at 0x11211dae6, in clang::tooling::ToolInvocation::run() + 1078
#22   Object "libclang-cpp.dylib", at 0x11211f4a8, in clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::__1::shared_ptr<clang::CompilerInvocation>, std::__1::shared_ptr<clang::PCHContainerOperations>) + 296
#21   Object "libclang-cpp.dylib", at 0x11211f6f5, in clang::tooling::FrontendActionFactory::runInvocation(std::__1::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::__1::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) + 373
#20   Object "libclang-cpp.dylib", at 0x111f4f0f7, in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 679
#19   Object "libclang-cpp.dylib", at 0x111fe1d3c, in clang::FrontendAction::Execute() + 76
#18   Object "libclang-cpp.dylib", at 0x10fef4a99, in clang::ParseAST(clang::Sema&, bool, bool) + 761
#17   Object "clang-uml", at 0x101cd5934, in clanguml::common::generators::diagram_ast_consumer<clanguml::sequence_diagram::model::diagram, clanguml::config::sequence_diagram, clanguml::sequence_diagram::visitor::translation_unit_visitor>::HandleTranslationUnit(clang::ASTContext&) + 52
#16   Object "clang-uml", at 0x101cdc995, in clang::RecursiveASTVisitor<clanguml::sequence_diagram::visitor::translation_unit_visitor>::TraverseDecl(clang::Decl*) + 3909
#15   Object "clang-uml", at 0x101ce9567, in clang::RecursiveASTVisitor<clanguml::sequence_diagram::visitor::translation_unit_visitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) + 599
#14   Object "clang-uml", at 0x101d41f77, in clang::RecursiveASTVisitor<clanguml::sequence_diagram::visitor::translation_unit_visitor>::TraverseDeclContextHelper(clang::DeclContext*) + 199
#13   Object "clang-uml", at 0x101cdbe29, in clang::RecursiveASTVisitor<clanguml::sequence_diagram::visitor::translation_unit_visitor>::TraverseDecl(clang::Decl*) + 985
#12   Object "clang-uml", at 0x101cdf594, in clang::RecursiveASTVisitor<clanguml::sequence_diagram::visitor::translation_unit_visitor>::TraverseNamespaceDecl(clang::NamespaceDecl*) + 164
#11   Object "clang-uml", at 0x101d41f77, in clang::RecursiveASTVisitor<clanguml::sequence_diagram::visitor::translation_unit_visitor>::TraverseDeclContextHelper(clang::DeclContext*) + 199
#10   Object "clang-uml", at 0x101cdc1b0, in clang::RecursiveASTVisitor<clanguml::sequence_diagram::visitor::translation_unit_visitor>::TraverseDecl(clang::Decl*) + 1888
#9    Object "clang-uml", at 0x101ce2d61, in clang::RecursiveASTVisitor<clanguml::sequence_diagram::visitor::translation_unit_visitor>::TraverseClassTemplatePartialSpecializationDecl(clang::ClassTemplatePartialSpecializationDecl*) + 81
#8    Object "clang-uml", at 0x101d5906c, in clang::RecursiveASTVisitor<clanguml::sequence_diagram::visitor::translation_unit_visitor>::WalkUpFromClassTemplatePartialSpecializationDecl(clang::ClassTemplatePartialSpecializationDecl*) + 44
#7    Object "clang-uml", at 0x101d5900c, in clang::RecursiveASTVisitor<clanguml::sequence_diagram::visitor::translation_unit_visitor>::WalkUpFromClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl*) + 92
#6    Object "clang-uml", at 0x1029c0427, in clanguml::sequence_diagram::visitor::translation_unit_visitor::VisitClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl*) + 855
#5    Object "clang-uml", at 0x1029c0fc7, in clanguml::sequence_diagram::visitor::translation_unit_visitor::process_template_specialization(clang::ClassTemplateSpecializationDecl*) + 1399
#4    Object "clang-uml", at 0x1029d2935, in clanguml::sequence_diagram::visitor::translation_unit_visitor::process_template_specialization_argument(clang::ClassTemplateSpecializationDecl const*, clanguml::sequence_diagram::model::class_&, clang::TemplateArgument const&, unsigned long, bool) + 437
#3    Object "clang-uml", at 0x1020f44a9, in clanguml::common::model::template_parameter::set_name(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 521
#2    Object "libsystem_c.dylib", at 0x7ff8152060ca, in __assert_rtn + 313
#1    Object "libsystem_c.dylib", at 0x7ff815206d23, in abort + 122
#0    Object "libsystem_pthread.dylib", at 0x7ff8152bb1ff, in pthread_kill + 263
yairfine commented 11 months ago

Thank you! @bkryza

kinuris commented 4 months ago

Hey, I know this issue has been closed and marked as fixed but I'm having a similar issue in MacOS 14.5 (Apple Silicon).

Compiling with:

export CC=/opt/homebrew/opt/llvm@16/bin/clang
export CXX=/opt/homebrew/opt/llvm@16/bin/clang++

LLVM_VERSION=16 make release LLVM_DIR=/opt/homebrew/opt/llvm@16/lib/cmake/llvm/

Running ./release/src/clang-uml --version outputs:

clang-uml 0.5.3-2-gc0f5d5f
Copyright (C) 2021-2024 Bartek Kryza <bkryza@gmail.com>
Darwin arm64 23.5.0
Built against LLVM/Clang libraries version: 16.0.6
Using LLVM/Clang libraries version: Homebrew clang version 16.0.6

Running ./release/src/clang-uml --help gives me a bus error.

I tried running the command that worked for yairfine (replacing opt/llvm with opt/llvm@16), which builds successfully but still gives me a bus error.

Thank you for any help in advance.

bkryza commented 4 months ago

@kinuris I don't have access to an arm64 macbook so I can't reproduce, but if you could rebuild clang-uml in debug mode (just run make debug instead of make release) and try to run it again. If it crashes it should print a detailed stack trace that could help me trace the cause of this issue...

kinuris commented 4 months ago

Thanks for the speedy response.

Building it in debug mode and running:

$ ./debug/src/clang-uml --help
bus error  ./debug/src/clang-uml

Running:

$ ./debug/src/clang-uml
[info] [tid 1149278] [cli_handler.cc:306] Loaded clang-uml config from .clang-uml
[info] [tid 1149278] [cli_handler.cc:334] Loading compilation database from /Users/my.acct/.Trash/clang-uml/debug directory
[info] [tid 1149327] [generators.h:367] Generating diagram architecture_package
[info] [tid 1149329] [generators.h:367] Generating diagram architecture_visitors_class
[info] [tid 1149328] [generators.h:367] Generating diagram class_diagram_generator_sequence
[info] [tid 1149330] [generators.h:367] Generating diagram class_model_class
[info] [tid 1149331] [generators.h:367] Generating diagram class_translation_unit_visitor
[info] [tid 1149332] [generators.h:367] Generating diagram cli_handle_options_sequence
[info] [tid 1149333] [generators.h:367] Generating diagram comment_visitor_hierarchy_class
[info] [tid 1149334] [generators.h:367] Generating diagram common_model_class
bus error  ./debug/src/clang-uml
bkryza commented 4 months ago

@kinuris Thanks but unfortunately it seems the stack trace is not produced on arm macos. Another possibility is to use lldb to run in debugger but on macos, but this requires that you can enable developer mode:

$ DevToolsSecurity -enable

and then:

$ lldb -- debug/src/clang-uml --help
(lldb) run
kinuris commented 4 months ago

Sorry for the late reply, just ran it.

$ lldb -- debug/src/clang-uml --help
(lldb) target create "debug/src/clang-uml"
Current executable set to '/Users/my.acct/.Trash/clang-uml/debug/src/clang-uml' (arm64).
(lldb) settings set -- target.run-args  "--help"
(lldb) run
Process 92103 launched: '/Users/my.acct/.Trash/clang-uml/debug/src/clang-uml' (arm64)
Process 92103 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=261, address=0xdac11410)
    frame #0: 0x00000001950d094c libunwind.dylib`_Unwind_GetIP + 224
libunwind.dylib`_Unwind_GetIP:
->  0x1950d094c <+224>: autib  x16, x0
    0x1950d0950 <+228>: mov    x17, x16
    0x1950d0954 <+232>: xpaci  x17
    0x1950d0958 <+236>: cmp    x16, x17
bkryza commented 4 months ago

@kinuris I still can't reproduce it on either Linux or macos (Intel based), however I did some search and found that in some cases this can be mitigated by building application with GCC instead of LLVM. clang-uml can be easily compiled with GCC, as long as it's linked to the libLLVM, but you would need to install gcc in your homebrew setup and adjust the CC and CXX variables.

Sorry that it's mostly guess work from my side but I can't verify this myself...

bkryza commented 4 months ago

@kinuris I think I solved the issue, I've also added a macOS Github Action which passes.

Basically it seems that when building something with LLVM installed using brew you need to explicitly link to it's own libc++ implementation, otherwise any thrown exception will cause bus error.

Please try:

make clean
export CC=/opt/homebrew/opt/llvm@16/bin/clang
export CXX=/opt/homebrew/opt/llvm@16/bin/clang++

CMAKE_PREFIX=/opt/homebrew/opt/llvm@16/lib/cmake/llvm/ CMAKE_EXE_LINKER_FLAGS="-L/opt/homebrew/opt/llvm@16/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm@16/lib/c++" make release 

release/src/clang-uml --help

You can also switch to either LLVM 17 or 18 (the Github Action I created uses the latest 18.1.8 - see here).

I've also update the docs.

kinuris commented 4 months ago

@bkryza Thanks for looking into this.

It works now! I don't know why but for some reason it only works when built using llvm-18, in llvm-16 it just spits out a bus error with no logs even on make debug.