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

Segfault when parsing template specializations involving nested type access #748

Open
anarthal opened this issue Dec 2, 2024 · 1 comment
Assignees

Comments

@anarthal
Copy link

anarthal commented Dec 2, 2024

MrDocs version: develop (2024-10-24).

The following:

#include <type_traits>

template <class T, class = void>
struct S
{
    void store(const void*) {}
};

template <class T>
struct S<T, std::void_t<typename T::a::b>>
{
    void store(const void*) {}
};

int main() {}

Segfaults with the default config options:

-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ruben/workspace/mrdocs-repro/doc/reference-output/.temp/build

mrdocs: /__w/mrdocs/third-party/llvm-project/install/include/clang/AST/Type.h:957: const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.
PLEASE submit a bug report to https://github.com/cppalliance/mrdocs/issues/ and include the crash backtrace.
Stack dump:
0.      <eof> parser at end of file
 #0 0x0000000003245bb0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x3245bb0)
 #1 0x0000000003242b3b SignalHandler(int) Signals.cpp:0:0
 #2 0x0000000003384670 __restore_rt libc_sigaction.o:0:0
 #3 0x00000000033a821c __pthread_kill (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x33a821c)
 #4 0x00000000033845ee raise (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x33845ee)
 #5 0x000000000043aed9 abort (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x43aed9)
 #6 0x000000000043adf5 _nl_load_domain.cold loadmsgcat.o:0:0
 #7 0x000000000337cac7 (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x337cac7)
 #8 0x000000000055d24d clang::mrdocs::(anonymous namespace)::ASTVisitor::getSFINAETemplate(clang::QualType, bool) (.isra.0) ASTVisitor.cpp:0:0
 #9 0x000000000056251d clang::mrdocs::(anonymous namespace)::ASTVisitor::isSFINAEType(clang::QualType) ASTVisitor.cpp:0:0
#10 0x0000000000565eca clang::mrdocs::(anonymous namespace)::TerminalTypeVisitor<clang::mrdocs::(anonymous namespace)::TypeInfoBuilder>::Visit(clang::QualType) (.isra.0) ASTVisitor.cpp:0:0
#11 0x00000000005667e1 clang::mrdocs::(anonymous namespace)::ASTVisitor::buildTypeInfo(clang::QualType, clang::mrdocs::(anonymous namespace)::ASTVisitor::ExtractMode) ASTVisitor.cpp:0:0
#12 0x000000000056783f clang::mrdocs::(anonymous namespace)::ASTVisitor::buildTemplateArg(clang::TemplateArgument const&) ASTVisitor.cpp:0:0
#13 0x0000000000567cf0 void clang::mrdocs::(anonymous namespace)::ASTVisitor::buildTemplateArgs<std::ranges::transform_view<std::ranges::owning_view<llvm::ArrayRef<clang::TemplateArgumentLoc>>, clang::mrdocs::(anonymous namespace)::ASTVisitor::buildTemplateArgs(std::vector<std::unique_ptr<clang::mrdocs::TArg, std::default_delete<clang::mrdocs::TArg>>, std::allocator<std::unique_ptr<clang::mrdocs::TArg, std::default_delete<clang::mrdocs::TArg>>>>&, clang::ASTTemplateArgumentListInfo const*)::'lambda'(auto&)>>(std::vector<std::unique_ptr<clang::mrdocs::TArg, std::default_delete<clang::mrdocs::TArg>>, std::allocator<std::unique_ptr<clang::mrdocs::TArg, std::default_delete<clang::mrdocs::TArg>>>>&, auto&&) ASTVisitor.cpp:0:0
#14 0x0000000000577a01 void clang::mrdocs::(anonymous namespace)::ASTVisitor::traverse<clang::ClassTemplatePartialSpecializationDecl>(clang::ClassTemplatePartialSpecializationDecl*, clang::ClassTemplateDecl*) ASTVisitor.cpp:0:0
#15 0x0000000000576ffa clang::mrdocs::(anonymous namespace)::ASTVisitor::traverseContext(clang::DeclContext*) ASTVisitor.cpp:0:0
#16 0x0000000000576969 void clang::mrdocs::(anonymous namespace)::ASTVisitor::traverseDecl<>(clang::Decl*) ASTVisitor.cpp:0:0
#17 0x0000000000579998 clang::mrdocs::(anonymous namespace)::ASTVisitorConsumer::HandleTranslationUnit(clang::ASTContext&) ASTVisitor.cpp:0:0
#18 0x00000000008692cc clang::ParseAST(clang::Sema&, bool, bool) (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x8692cc)
#19 0x00000000007a6799 clang::FrontendAction::Execute() (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x7a6799)
#20 0x00000000007264be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x7264be)
#21 0x00000000006e00d2 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x6e00d2)
#22 0x00000000006d7111 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x6d7111)
#23 0x00000000006db0b8 clang::tooling::ToolInvocation::run() (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x6db0b8)
#24 0x00000000006dd414 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x6dd414)
#25 0x00000000004ce0b6 clang::mrdocs::CorpusImpl::build(std::shared_ptr<clang::mrdocs::ConfigImpl const> const&, clang::tooling::CompilationDatabase const&)::'lambda'(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>) const CorpusImpl.cpp:0:0
#26 0x00000000004cfd0e clang::mrdocs::CorpusImpl::build(std::shared_ptr<clang::mrdocs::ConfigImpl const> const&, clang::tooling::CompilationDatabase const&) (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x4cfd0e)
#27 0x000000000048fafb clang::mrdocs::DoGenerateAction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, clang::mrdocs::ReferenceDirectories const&, char const**) (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x48fafb)
#28 0x00000000004981ef clang::mrdocs::mrdocs_main(int, char const**) (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x4981ef)
#29 0x000000000043b7cd main (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x43b7cd)
#30 0x000000000336b678 __libc_start_call_main libc-start.o:0:0
#31 0x000000000336d840 __libc_start_main (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x336d840)
#32 0x0000000000487ca5 _start (/opt/mrdocs-develop-2024-10-24/bin/mrdocs+0x487ca5)
Aborted (core dumped)

Compilation database:

[
{
  "directory": "[redacted]/mrdocs-repro/doc/build",
  "command": "/usr/bin/c++    -o CMakeFiles/main.dir/main.cpp.o -c [redacted]/mrdocs-repro/main.cpp",
  "file": "[redacted]/mrdocs-repro/main.cpp"
}
]
@anarthal
Copy link
Author

anarthal commented Dec 2, 2024

This issue blocks the generation of Boost.MySQL docs, since connection.hpp uses a similar pattern.

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

No branches or pull requests

2 participants