Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-22551

clangbackend crashes when switching from .h to respective .cpp

    XMLWordPrintable

    Details

    • Platform/s:
      Linux/X11

      Description

      if the .cpp file isn't listed in the *pro file, then opening an header, and F4 to switch to it will crash clang backend

      See attached test-case.
      1. Open the .pro file with QtCreator
      2. Ctrl+K, choose Foo.h
      3. F4 (which should switch to Foo.cpp, and crash clangbackend)

      Backtrace:

      #0  0x00007f4e83c56584 in clang::NestedNameSpecifier::isDependent() const () from /usr/lib/qtcreator/../libclangAST.so.8
      #1  0x00007f4e8407110b in clang::Sema::computeDeclContext(clang::CXXScopeSpec const&, bool) () from /usr/lib/qtcreator/../libclangSema.so.8
      #2  0x00007f4e84073a2e in clang::Sema::ActOnCXXEnterDeclaratorScope(clang::Scope*, clang::CXXScopeSpec&) () from /usr/lib/qtcreator/../libclangSema.so.8
      #3  0x00007f4e83832cab in ?? () from /usr/lib/qtcreator/../libclangParse.so.8
      #4  0x00007f4e8384eb3b in clang::Parser::ParseDirectDeclarator(clang::Declarator&) () from /usr/lib/qtcreator/../libclangParse.so.8
      #5  0x00007f4e83842ef7 in clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::*)(clang::Declarator&)) () from /usr/lib/qtcreator/../libclangParse.so.8
      #6  0x00007f4e83849404 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) () from /usr/lib/qtcreator/../libclangParse.so.8
      #7  0x00007f4e838d2376 in clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) () from /usr/lib/qtcreator/../libclangParse.so.8
      #8  0x00007f4e838d2d32 in ?? () from /usr/lib/qtcreator/../libclangParse.so.8
      #9  0x00007f4e838d96f1 in clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) () from /usr/lib/qtcreator/../libclangParse.so.8
      #10 0x00007f4e83859fc7 in clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) () from /usr/lib/qtcreator/../libclangParse.so.8
      #11 0x00007f4e8385acb9 in clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) () from /usr/lib/qtcreator/../libclangParse.so.8
      #12 0x00007f4e8384c4cd in clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) () from /usr/lib/qtcreator/../libclangParse.so.8
      #13 0x00007f4e838d971b in clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) () from /usr/lib/qtcreator/../libclangParse.so.8
      #14 0x00007f4e83859fc7 in clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) () from /usr/lib/qtcreator/../libclangParse.so.8
      #15 0x00007f4e8385acb9 in clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) () from /usr/lib/qtcreator/../libclangParse.so.8
      #16 0x00007f4e8384c4cd in clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) () from /usr/lib/qtcreator/../libclangParse.so.8
      #17 0x00007f4e838d971b in clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) () from /usr/lib/qtcreator/../libclangParse.so.8
      #18 0x00007f4e838da36a in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) () from /usr/lib/qtcreator/../libclangParse.so.8
      #19 0x00007f4e83828818 in clang::ParseAST(clang::Sema&, bool, bool) () from /usr/lib/qtcreator/../libclangParse.so.8
      #20 0x00007f4e84e454f6 in clang::FrontendAction::Execute() () from /usr/lib/qtcreator/../libclangFrontend.so.8
      #21 0x00007f4e84e81f72 in clang::PrecompiledPreamble::Build(clang::CompilerInvocation const&, llvm::MemoryBuffer const*, clang::PreambleBounds, clang::DiagnosticsEngine&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::shared_ptr<clang::PCHContainerOperations>, bool, clang::PreambleCallbacks&) ()
         from /usr/lib/qtcreator/../libclangFrontend.so.8
      #22 0x00007f4e84de4733 in clang::ASTUnit::getMainBufferWithPrecompiledPreamble(std::shared_ptr<clang::PCHContainerOperations>, clang::CompilerInvocation&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, bool, unsigned int) () from /usr/lib/qtcreator/../libclangFrontend.so.8
      #23 0x00007f4e84dec56d in clang::ASTUnit::LoadFromCompilerInvocation(std::shared_ptr<clang::PCHContainerOperations>, unsigned int, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) () from /usr/lib/qtcreator/../libclangFrontend.so.8
      #24 0x00007f4e84df0a12 in clang::ASTUnit::LoadFromCommandLine(char const**, char const**, std::shared_ptr<clang::PCHContainerOperations>, llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>, llvm::StringRef, bool, bool, llvm::ArrayRef<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, llvm::MemoryBuffer*> >, bool, unsigned int, clang::TranslationUnitKind, bool, bool, bool, clang::SkipFunctionBodiesScope, bool, bool, bool, llvm::Optional<llvm::StringRef>, std::unique_ptr<clang::ASTUnit, std::default_delete<clang::ASTUnit> >*, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) ()
         from /usr/lib/qtcreator/../libclangFrontend.so.8
      #25 0x00007f4e8595ed72 in ?? () from /usr/lib/qtcreator/../libclang.so.8
      #26 0x00007f4e8595f96c in ?? () from /usr/lib/qtcreator/../libclang.so.8
      #27 0x00007f4e7eca9203 in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) () from /usr/lib/qtcreator/../libLLVM-8.so
      #28 0x00007f4e8595c313 in clang_parseTranslationUnit2FullArgv () from /usr/lib/qtcreator/../libclang.so.8
      #29 0x00007f4e8595c6bb in clang_parseTranslationUnit2 () from /usr/lib/qtcreator/../libclang.so.8
      

      output:

      2019-06-11T09:00:13 Clang Code Model: Error: The clangbackend process has finished unexpectedly and was restarted.
      Error in ClangCodeModelServer::documentsClosed: Document '/home/username/projects/test/bug/Foo.cpp' does not exists!
      "ClangCodeModelConnectionClient" LocalSocket Error: "QLocalSocket: Remote closed"
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              kosjar Nikolai Kosjar
              Reporter:
              iamsergio Sergio Martins
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes