DUContext: Make (newer) ASAN 5.0 happy

Authored by kfunk on Aug 4 2017, 9:08 AM.

Description

DUContext: Make (newer) ASAN 5.0 happy

ASAN trace:

27043==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7fe75b891140 at pc 0x7fe7992e8fdc bp 0x7fe75b890740 sp 0x7fe75b890738

WRITE of size 4 at 0x7fe75b891140 thread T13 (Queue(0x6040005)
0 0x7fe7992e8fdb in std::__atomic_base<int>::operator--() /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/atomic_base.h:304:16
1 0x7fe7992e8f64 in bool QAtomicOps<int>::deref<int>(std::atomic<int>&) /usr/include/x86_64-linux-gnu/qt5/QtCore/qatomic_cxx11.h:271:16
2 0x7fe7992e8dd4 in QBasicAtomicInteger<int>::deref() /usr/include/x86_64-linux-gnu/qt5/QtCore/qbasicatomic.h:111:42
3 0x7fe7994a2c3b in QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem>::~QExplicitlySharedDataPointer() /usr/include/x86_64-linux-gnu/qt5/QtCore/qshareddata.h:165:63
4 0x7fe7994d278c in QVarLengthArray<QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem>, 256>::~QVarLengthArray() /usr/include/x86_64-linux-gnu/qt5/QtCore/qvarlengtharray.h:87:21
5 0x7fe7994a2ac4 in KDevVarLengthArray<QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem>, 256>::~KDevVarLengthArray() /home/kfunk/devel/src/kf5/kdevplatform-stable/util/kdevvarlengtharray.h:31:7
6 0x7fe799484403 in KDevelop::DUContext::findDeclarations(KDevelop::QualifiedIdentifier const&, KDevelop::CursorInRevision const&, KDevelop::TypePtr<KDevelop::AbstractType> const&, KDevelop::TopDUContext const*, QFlags<KDevelop::DUContext::SearchFlag>) const /home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/ducontext.cpp:783:1
7 0x7fe76dbde030 in ClangHelpers::findDeclaration(CXSourceLocation, KDevelop::QualifiedIdentifier, KDevelop::ReferencedTopDUContext const&) /home/kfunk/devel/src/kf5/kdevelop-stable/languages/clang/duchain/clanghelpers.cpp:207:34
8 0x7fe76dbdf6b0 in ClangHelpers::findDeclaration(CXCursor, QHash<void*, KDevelop::ReferencedTopDUContext> const&) /home/kfunk/devel/src/kf5/kdevelop-stable/languages/clang/duchain/clanghelpers.cpp:254:12
9 0x7fe76da81cf2 in (anonymous namespace)::Visitor::findDeclaration(CXCursor) const /home/kfunk/devel/src/kf5/kdevelop-stable/languages/clang/duchain/builder.cpp:1225:17
10 0x7fe76da7d3b6 in (anonymous namespace)::Visitor::Visitor(CXTranslationUnitImpl*, void*, QHash<void*, KDevelop::ReferencedTopDUContext> const&, bool) /home/kfunk/devel/src/kf5/kdevelop-stable/languages/clang/duchain/builder.cpp:1394:25
...

Address 0x7fe75b891140 is located in stack of thread T13 (Queue(0x6040005) at offset 2240 in frame
0 0x7fe799483abf in KDevelop::DUContext::findDeclarations(KDevelop::QualifiedIdentifier const&, KDevelop::CursorInRevision const&, KDevelop::TypePtr<KDevelop::AbstractType> const&, KDevelop::TopDUContext const*, QFlags<KDevelop::DUContext::SearchFlag>) const /home/kfunk/devel/src/kf5/kdevplatform-stable/language/duchain/ducontext.cpp:769

This frame has 8 object(s):

[32, 36) 'flags'
[48, 2112) 'identifiers' (line 773)
[2240, 4320) 'item' (line 776) <== Memory access at offset 2240 is inside this variable
[4448, 4456) 'ref.tmp' (line 776)
[4480, 4488) 'ref.tmp7' (line 778)
[4512, 4520) 'ref.tmp11' (line 780)
[4544, 4560) 'ref.tmp13' (line 780)
[4576, 4580) 'agg.tmp'

Details

Committed
kfunkAug 4 2017, 9:22 AM
Parents
R33:0714e5d52abe: TypeRegister: Stronger assumptions in debug mode
Branches
Unknown
Tags
Unknown