Summary: | test_duchain-clang fails | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | RJVB <rjvbertin> |
Component: | general | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED WORKSFORME | ||
Severity: | crash | CC: | kilo |
Priority: | NOR | Keywords: | drkonqi |
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
See Also: | https://bugs.kde.org/show_bug.cgi?id=379669 | ||
Latest Commit: | Version Fixed In: | ||
Attachments: |
up-to-date crash report
patch-avoid-duchain-hang-on-exit.diff patch-topcontext-crashfix.diff patch-topcontext-crashfix.diff patch-topcontext-crashfix.diff |
Description
RJVB
2017-04-20 15:18:28 UTC
I cannot reproduce it. SOFTWARE/OS VERSIONS Linux/KDE Plasma: KDE Plasma Version: 5.12.8 KDE Frameworks Version: 5.45.0 Qt Version: Qt 5.9.4 (built against 5.9.4) XCB LLVM/CLANG: 8.0.1 Created attachment 119672 [details]
up-to-date crash report
I'm still getting the crash in the current 5.3 branch head, with essentially the same backtrace. It looks like an access of a stale object, possibly one that should have been deleted via deleteLater().
This could be the sort of bug that remains dormant in a debug build, or in a build with a different compiler (or optimisation options).
I am now using clang 5.0.2 with -Ofast, Qt 5.9.8 and KF5 5.52.0 .
Same crash with the same code, libraries and compiler on Mac OS X 10.9.5 . And re: the heisenbug nature: the bug doesn't trigger when I run the test through valgrind. FWIW, this happens during the global shutdown phase, apparently *after* the sdDUChainPrivate global variable was deleted. This probably means there's a nasty bug elsewhere which causes freed memory to be overwritten. If that's the case my issue should disappear if I make the m_destroyed member var a static global bool; will try that. So it's not that; the crash occurs before sdDUChainPrivate is deleted. However, m_openDocumentContexts clearly contains stale references which currently cannot be detected properly. I tried using `sdDUChainPrivate->m_referenceCounts[top] == 0` as a test before the check on top->url() but that catches only part of the offending cases. In other words, TopDUContexts are apparently deleted also without bumping their refcount to 0 . I tried setting m_dynamicData=nullptr in ~TopDUContext() and then got another crash in ~DUContext() where I see this: TopDUContext* top = topContext(); if(!top->deleting() || !top->isOnDisk()) { How can that be correct if ~DUContext() can be called after its associated TopDUContext has been deleted?! Hmm, I'm a bit confused, but I get the output below. This time I simply used the pre-insalled versions in my openSuSE 15.0 LEAP. Am I missing something? plugins/clang/tests/test_duchain-clang ********* Start testing of TestDUChain ********* Config: Using QtTest library 5.9.4, Qt 5.9.4 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 7.3.1 20180323 [gcc-7-branch revision 258812]) QWARN : TestDUChain::initTestCase() kf5.kxmlgui: cannot find .rc file "test_duchain-clangui.rc" for component "test_duchain-clang" PASS : TestDUChain::initTestCase() QDEBUG : TestDUChain::testComments(invalid1) kdevelop.plugins.clang: Full Clang version: "clang version 7.0.1 (tags/RELEASE_701/final 349238)" QDEBUG : TestDUChain::testComments(invalid1) kdevelop.plugins.clang: Detected Clang version: "7.0.1" QDEBUG : TestDUChain::testComments(invalid1) kdevelop.plugins.clang: Using builtin dir: "/usr/lib64/clang/7.0.1/include" QDEBUG : TestDUChain::testComments(invalid1) kdevelop.plugins.clang: Passing extra arguments to clang: QVector() PASS : TestDUChain::testComments(invalid1) PASS : TestDUChain::testComments(invalid2) PASS : TestDUChain::testComments(basic1) PASS : TestDUChain::testComments(basic2) PASS : TestDUChain::testComments(enumerator) PASS : TestDUChain::testComments(comment-formatting) PASS : TestDUChain::testComments(comment-doxygen-tags) PASS : TestDUChain::testElaboratedType(namespace) PASS : TestDUChain::testElaboratedType(enum) PASS : TestDUChain::testElaboratedType(typedef) PASS : TestDUChain::testInclude() XFAIL : TestDUChain::testMissingInclude() Base class isn't assigned correctly Loc: [../plugins/clang/tests/test_duchain.cpp(305)] PASS : TestDUChain::testMissingInclude() PASS : TestDUChain::testIncludeLocking() PASS : TestDUChain::testReparse() PASS : TestDUChain::testReparseError() PASS : TestDUChain::testTemplate() PASS : TestDUChain::testNamespace() PASS : TestDUChain::testAutoTypeDeduction() /tmp/testfile_H16077.cpp:1:46: error: expected ';' after struct PASS : TestDUChain::testTypeDeductionInTemplateInstantiation() PASS : TestDUChain::testVirtualMemberFunction() PASS : TestDUChain::testBaseClasses() QDEBUG : TestDUChain::testReparseBaseClasses() run: 0 QDEBUG : TestDUChain::testReparseBaseClasses() run: 1 PASS : TestDUChain::testReparseBaseClasses() QDEBUG : TestDUChain::testReparseBaseClassesTemplates() run: 0 QDEBUG : TestDUChain::testReparseBaseClassesTemplates() run: 1 PASS : TestDUChain::testReparseBaseClassesTemplates() PASS : TestDUChain::testGetInheriters(inline) PASS : TestDUChain::testGetInheriters(outline) PASS : TestDUChain::testGlobalFunctionDeclaration() PASS : TestDUChain::testFunctionDefinitionVsDeclaration() PASS : TestDUChain::testEnsureNoDoubleVisit() XFAIL : TestDUChain::testReparseWithAllDeclarationsContextsAndUses() Skipping of function bodies is disabled for now Loc: [../plugins/clang/tests/test_duchain.cpp(1027)] PASS : TestDUChain::testReparseWithAllDeclarationsContextsAndUses() XFAIL : TestDUChain::testReparseOnDocumentActivated() Skipping of function bodies was disabled for now Loc: [../plugins/clang/tests/test_duchain.cpp(1063)] QWARN : TestDUChain::testReparseOnDocumentActivated() kf5.kxmlgui: cannot find .rc file "test_duchain-clangui.rc" for component "test_duchain-clang" PASS : TestDUChain::testReparseOnDocumentActivated() QDEBUG : TestDUChain::testParsingEnvironment() kdevelop.plugins.clang: TU environment changed, require update "/tmp/testfile_R16077.cpp" TU url: "/tmp/testfile_R16077.cpp" old hash: 1382218283 new hash: 1662501796 QDEBUG : TestDUChain::testParsingEnvironment() kdevelop.plugins.clang: Found better quality environment, require update: "/tmp/testfile_R16077.cpp" new environment quality: 2 old environment quality: 1 QDEBUG : TestDUChain::testParsingEnvironment() kdevelop.plugins.clang: TU environment changed, require update "/tmp/testfile_R16077.cpp" TU url: "/tmp/testfile_R16077.cpp" old hash: 1662501796 new hash: 3485664175 QDEBUG : TestDUChain::testParsingEnvironment() kdevelop.plugins.clang: TU environment changed, require update "/tmp/testfile_R16077.cpp" TU url: "/tmp/testfile_R16077.cpp" old hash: 1662501796 new hash: 3485664175 PASS : TestDUChain::testParsingEnvironment() PASS : TestDUChain::testSystemIncludes() PASS : TestDUChain::testReparseInclude() QDEBUG : TestDUChain::testReparseChangeEnvironment() kdevelop.plugins.clang: TU environment changed, require update "/tmp/testfile_K16077.h" TU url: "/tmp/testfile_K16077.cpp" old hash: 1382218283 new hash: 3178109628 QDEBUG : TestDUChain::testReparseChangeEnvironment() kdevelop.plugins.clang: TU environment changed, require update "/tmp/testfile_K16077.h" TU url: "/tmp/testfile_K16077.cpp" old hash: 3178109628 new hash: 776131470 PASS : TestDUChain::testReparseChangeEnvironment() PASS : TestDUChain::testMacrosRanges() PASS : TestDUChain::testMacroUses() XFAIL : TestDUChain::testHeaderParsingOrder1() the use could not be created because the corresponding declaration didn't exist yet Loc: [../plugins/clang/tests/test_duchain.cpp(1275)] PASS : TestDUChain::testHeaderParsingOrder1() PASS : TestDUChain::testHeaderParsingOrder2() QDEBUG : TestDUChain::testMacroDependentHeader() DECL RANGE: [ (0, 7) -> (0, 7) ] QDEBUG : TestDUChain::testMacroDependentHeader() CTX RANGE: [ (0, 0) -> (0, 49) ] PASS : TestDUChain::testMacroDependentHeader() PASS : TestDUChain::testNestedImports() PASS : TestDUChain::testEnvironmentWithDifferentOrderOfElements() PASS : TestDUChain::testReparseMacro() PASS : TestDUChain::testMultiLineMacroRanges() PASS : TestDUChain::testNestedMacroRanges() PASS : TestDUChain::testGotoStatement() PASS : TestDUChain::testRangesOfOperatorsInsideMacro() PASS : TestDUChain::testActiveDocumentHasASTAttached() PASS : TestDUChain::testActiveDocumentsGetBestPriority() PASS : TestDUChain::testUsesCreatedForDeclarations() PASS : TestDUChain::testReparseIncludeGuard() PASS : TestDUChain::testExternC() PASS : TestDUChain::testLambda() PASS : TestDUChain::testReparseUnchanged(include-guards) PASS : TestDUChain::testReparseUnchanged(template-default-parameters) PASS : TestDUChain::testTypeAliasTemplate() PASS : TestDUChain::testDeclarationsInsideMacroExpansion() Top-Context "Global" (owner: 0x0 ) 0x7f4490003600 "" [ "" ] [ (0, 0) -> (2147483647, 2147483647) ] "/tmp/testfile_t16077.cpp" Declaration: "Foo< MatchingName >" [ "Foo< MatchingName >" ] 0x7f44901ef810 (internal ctx: 0x7f449002b0c0 ) [ (1, 46) -> (1, 49) ] , no definition, 0 use(s). Declaration: "class MatchingName" [ "MatchingName" ] 0x7f44903eab00 (internal ctx: 0x7f449031bd00 ) [ (3, 14) -> (3, 26) ] , defined, 1 use(s). File: "/tmp/testfile_t16077.cpp" Use: [ (4, 13) -> (4, 25) ] Context "Class" (owner: 0x7f44901ef810 ) 0x7f449002b0c0 "Foo< MatchingName >" [ "Foo< MatchingName >" ] [ (1, 8) -> (1, 49) ] "" 1 Declarations, 0 child-contexts Context "Class" (owner: 0x7f44903eab00 ) 0x7f449031bd00 "MatchingName" [ "MatchingName" ] [ (3, 8) -> (3, 42) ] "" 1 Declarations, 1 child-contexts Context "Function" (owner: 0x7f4490260380 ) 0x7f449002a700 "bar" [ "MatchingName::bar" ] [ (3, 29) -> (3, 39) ] "" 0 Declarations, 0 child-contexts Context "Helper" (owner: 0x0 ) 0x7f44904057a0 "MatchingName" [ "MatchingName" ] [ (4, 8) -> (4, 37) ] "" 1 Declarations, 1 child-contexts Context "Function" (owner: 0x7f44903e9180 ) 0x7f44902696d0 "bar" [ "MatchingName::bar" ] [ (4, 8) -> (4, 37) ] "" 0 Declarations, 1 child-contexts Context "Other" (owner: 0x0 ) 0x7f44903e7e60 "" [ "MatchingName::bar" ] [ (4, 33) -> (4, 37) ] "" 0 Declarations, 0 child-contexts PASS : TestDUChain::testForwardTemplateTypeParameterContext() Top-Context "Global" (owner: 0x0 ) 0x7f4490269130 "" [ "" ] [ (0, 0) -> (2147483647, 2147483647) ] "/tmp/testfile_z16077.cpp" Declaration: "void foo (int)" [ "foo" ] 0x7f44880063a0 (internal ctx: 0x7f448820ea80 ) [ (2, 13) -> (2, 16) ] , no definition, 0 use(s). Declaration: "void bar (int)" [ "bar" ] 0x7f448834fe40 (internal ctx: 0x7f4488002580 ) [ (4, 13) -> (4, 16) ] , no definition, 0 use(s). Context "Function" (owner: 0x7f44880063a0 ) 0x7f448820ea80 "foo" [ "foo" ] [ (1, 8) -> (2, 26) ] "" 2 Declarations, 0 child-contexts Context "Function" (owner: 0x7f448834fe40 ) 0x7f4488002580 "bar" [ "bar" ] [ (4, 8) -> (4, 26) ] "" 1 Declarations, 0 child-contexts XFAIL : TestDUChain::testTemplateFunctionParameterName() We get two declarations, for both template and args :( Loc: [../plugins/clang/tests/test_duchain.cpp(1797)] XFAIL : TestDUChain::testTemplateFunctionParameterName() see above, this then triggers T T here Loc: [../plugins/clang/tests/test_duchain.cpp(1800)] PASS : TestDUChain::testTemplateFunctionParameterName() PASS : TestDUChain::testFriendDeclaration() PASS : TestDUChain::testVariadicTemplateArguments() PASS : TestDUChain::testGccCompatibility() PASS : TestDUChain::testQtIntegration() 1 problems encountered: "#include_next with absolute path [-Winclude-next-absolute-path]" "" [ (2, 12) -> (2, 30) ] PASS : TestDUChain::testHasInclude() PASS : TestDUChain::testSameFunctionDefinition() PASS : TestDUChain::cleanupTestCase() Totals: 66 passed, 0 failed, 0 skipped, 0 blacklisted, 10720ms ********* Finished testing of TestDUChain ********* I have no idea. I can no longer get the crash myself either on Linux, after I corrected something in a local mod (flagged by valgrind) that should be completely unrelated. The whole (top)ducontext structure is a bit of a cardhouse with some known instabilities (like sometimes getting in a closed loop on exit). If I understand the purpose of the ReferencedTopDUContext class correctly it's a kind of proof of that brittleness which can apparently lead to stale references being maintained and used at some point, under certain conditions. FWIW, I do have a patch in place that helps avoid the locking-on-exit issue I mentioned, but a priori that patch shouldn't be the source of my issue (it prints warnings when it takes preventive action and I'm not seeing any of those). (In reply to RJVB from comment #8) > I can no longer get the crash myself either on Linux Belay that: it just no longer crashes every time. Try it often enough and I still get the same crash. I started the test in an endless loop. It is behaving quite strange. There are two test steps that mostly succeed but sometimes fail. I also got a crash, but the Backtrace is different: #0 0x00007f9186b26120 in raise () from /lib64/libc.so.6 #1 0x00007f9186b27701 in abort () from /lib64/libc.so.6 #2 0x00007f9187825881 in qt_message_fatal (context=..., message=<synthetic pointer>...) at global/qlogging.cpp:1690 #3 QMessageLogger::fatal (this=this@entry=0x7f918fc8ba80 <QTest::FatalSignalHandler::FatalSignalHandler()::alternate_stack+14976>, msg=msg@entry=0x7f918fa7b4f0 "Received signal %d\n Function time: %dms Total time: %dms") at global/qlogging.cpp:796 #4 0x00007f918fa60353 in QTest::FatalSignalHandler::signal (signum=2) at qtestcase.cpp:1416 #5 <signal handler called> #6 0x00007f9186c4aa87 in __memset_avx2_unaligned_erms () from /lib64/libc.so.6 #7 0x00007f918db43e40 in KDevelop::ItemRepository<KDevelop::UsesItem, KDevelop::UsesRequestItem, true, true, 0u, 1048576u>::ItemRepository (this=0x7f910982f010, repositoryName=..., registry=0x23c9c80, repositoryVersion=1, manager=0x0) at ../kdevplatform/serialization/itemrepository.h:1127 #8 0x00007f918db43579 in KDevelop::UsesPrivate::UsesPrivate (this=0x7f910982f010) at ../kdevplatform/language/duchain/uses.cpp:119 #9 0x00007f918db42890 in KDevelop::Uses::Uses (this=0x7f918e34f328 <KDevelop::(anonymous namespace)::Q_QGS_sdDUChainPrivate::innerFunction()::holder+72>) at ../kdevplatform/language/duchain/uses.cpp:126 #10 0x00007f918da7759b in KDevelop::DUChainPrivate::DUChainPrivate (this=0x7f918e34f2e0 <KDevelop::(anonymous namespace)::Q_QGS_sdDUChainPrivate::innerFunction()::holder>) at ../kdevplatform/language/duchain/duchain.cpp:336 #11 0x00007f918da72170 in KDevelop::(anonymous namespace)::Q_QGS_sdDUChainPrivate::Holder::Holder (this=0x7f918e34f2e0 <KDevelop::(anonymous namespace)::Q_QGS_sdDUChainPrivate::innerFunction()::holder>) at ../kdevplatform/language/duchain/duchain.cpp:1186 #12 0x00007f918da721e0 in KDevelop::(anonymous namespace)::Q_QGS_sdDUChainPrivate::innerFunction () at ../kdevplatform/language/duchain/duchain.cpp:1186 #13 0x00007f918da7616b in QGlobalStatic<KDevelop::DUChainPrivate, KDevelop::(anonymous namespace)::Q_QGS_sdDUChainPrivate::innerFunction, KDevelop::(anonymous namespace)::Q_QGS_sdDUChainPrivate::guard>::operator-> ( this=0x7f918e74eb68 <KDevelop::sdDUChainPrivate>) at /usr/include/qt5/QtCore/qglobalstatic.h:139 #14 0x00007f918da724e4 in KDevelop::DUChain::self () at ../kdevplatform/language/duchain/duchain.cpp:1211 #15 0x00007f918da27910 in KDevelop::StaticAssistantsManager::StaticAssistantsManager (this=0x245ddf0, parent=0x259bd60) at ../kdevplatform/language/assistant/staticassistantsmanager.cpp:72 #16 0x00007f918f36ffb1 in KDevelop::LanguageController::initialize (this=0x259bd60) at ../kdevplatform/shell/languagecontroller.cpp:146 #17 0x00007f918f32740b in KDevelop::CorePrivate::initialize (this=0x21d1e80, mode=KDevelop::Core::Default, session=...) at ../kdevplatform/shell/core.cpp:242 #18 0x00007f918fca6880 in KDevelop::TestCore::initializeNonStatic (this=0x21daf60, mode=KDevelop::Core::Default, _session=...) at ../kdevplatform/tests/testcore.cpp:81 #19 0x00007f918fca6713 in KDevelop::TestCore::initialize (mode=KDevelop::Core::Default, session=...) at ../kdevplatform/tests/testcore.cpp:55 #20 0x000000000040de42 in TestDUChain::initTestCase (this=0x7ffd5b8aa840) at ../plugins/clang/tests/test_duchain.cpp:75 #21 0x00000000004400f4 in TestDUChain::qt_static_metacall (_o=0x7ffd5b8aa840, _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0x7ffd5b8aa520) at plugins/clang/tests/test_duchain-clang_autogen/EWIEGA46WW/moc_test_duchain.cpp:292 #22 0x00007f9187a17aa6 in QMetaMethod::invoke (this=this@entry=0x7ffd5b8aa780, object=object@entry=0x7ffd5b8aa840, connectionType=connectionType@entry=Qt::DirectConnection, returnValue=..., val0=..., val1=..., val2=..., val3=..., val4=..., val5=..., val6=..., val7=..., val8=..., val9=...) at kernel/qmetaobject.cpp:2222 #23 0x00007f918fa67f84 in QMetaMethod::invoke (val9=..., val8=..., val7=..., val6=..., val5=..., val4=..., val3=..., val2=..., val1=..., val0=..., connectionType=Qt::DirectConnection, object=0x7ffd5b8aa840, this=0x7ffd5b8aa780) at ../../include/QtCore/../../src/corelib/kernel/qmetaobject.h:123 #24 QTest::TestMethods::invokeTests (this=this@entry=0x7ffd5b8aa780, testObject=testObject@entry=0x7ffd5b8aa840) at qtestcase.cpp:1363 #25 0x00007f918fa685c3 in QTest::qExec (testObject=0x7ffd5b8aa840, argc=<optimized out>, argv=0x7ffd5b8aa968) at qtestcase.cpp:1797 #26 0x000000000040dc12 in main (argc=1, argv=0x7ffd5b8aa968) at ../plugins/clang/tests/test_duchain.cpp:64 Created attachment 119708 [details]
patch-avoid-duchain-hang-on-exit.diff
Yes, your backtrace looks very different in that AFAICS it happens during an initialisation phase. It is of course possible that this is another case that my duchain patch prevents, but what branch are you working on?
I'm attaching the duchain patch in case you want to try it. It's attached to another bug report but I don't have the time right now to dig that one up. The patch applies to the 5.3 branch, I hope it will too to the main branch (if you're using that) without too much hassle. I'll try to find time to try *without* the patch on my end.
I to am noticing a few tests that fail sometimes; I haven't yet been able to link that to the issue at hand.
Created attachment 119731 [details]
patch-topcontext-crashfix.diff
I finally found a way to prevent accessing stale references, by keeping track in of every ReferencedTopDUContext in each TopDUContext instance. This way the ReferencedTopDUContext instances can be cleared when a TopDUContext is deleted (you can't delete these references because they are not always allocated dynamically).
This fixes the crashing issue for me on Mac.
Created attachment 119763 [details]
patch-topcontext-crashfix.diff
Updated fix that doesn't cause a crash itself in a multi-threaded context.
Created attachment 121379 [details]
patch-topcontext-crashfix.diff
Thank you for reporting this crash in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the crash with a recent software version? If you can reproduce the issue, please change the status to "CONFIRMED" when replying. Thank you! Dear Bug Submitter, This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging If you have already provided the requested information, please mark the bug as REPORTED so that the KDE team knows that the bug is ready to be confirmed. Thank you for helping us make KDE software even better for everyone! This bug has been in NEEDSINFO status with no change for at least 30 days. The bug is now closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging Thank you for helping us make KDE software even better for everyone! |