[llvm-bugs] [Bug 27936] New: Object invariant violation: FunctionType set

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 30 03:38:23 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27936

            Bug ID: 27936
           Summary: Object invariant violation: FunctionType set
           Product: clang
           Version: trunk
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eugvelesevich at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16434
  --> https://llvm.org/bugs/attachment.cgi?id=16434&action=edit
test

I added this assert code to FoldingSetImpl::InsertNode function
(lib/Support/FoldingSet.cpp):

 void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) {
+#ifndef NDEBUG
+  FoldingSetNodeID ID; 
+  GetNodeProfile(N, ID);
+  void *InsertPos2 = 0;
+  Node *N2 = FindNodeOrInsertPos(ID, InsertPos2);
+  assert(!N2 && "Node has already been in the set");
+  assert(InsertPos == InsertPos2 && "Incorrect InsertPos");
+#endif



The first assert fails (if compile with -std=c++11) on the attached test with
stacktrace:

llvm/lib/Support/FoldingSet.cpp:336: void
llvm::FoldingSetImpl::InsertNode(llvm::FoldingSetImpl::Node*, void*): Assertion
`!N2 && "Node has already been in the set"' failed.
...
#9 0x0000000002f94b5e
llvm::FoldingSetImpl::InsertNode(llvm::FoldingSetImpl::Node*, void*)
llvm/lib/Support/FoldingSet.cpp:337:0
#10 0x0000000002f94943 llvm::FoldingSetImpl::GrowHashTable()
llvm/lib/Support/FoldingSet.cpp:294:0
#11 0x0000000002f94bf0
llvm::FoldingSetImpl::InsertNode(llvm::FoldingSetImpl::Node*, void*)
llvm/lib/Support/FoldingSet.cpp:343:0
#12 0x0000000005275306 clang::ASTContext::getFunctionType(clang::QualType,
llvm::ArrayRef<clang::QualType>, clang::FunctionProtoType::ExtProtoInfo const&)
const clang/lib/AST/ASTContext.cpp:3115:0
#13 0x00000000052750c5 clang::ASTContext::getFunctionType(clang::QualType,
llvm::ArrayRef<clang::QualType>, clang::FunctionProtoType::ExtProtoInfo const&)
const clang/lib/AST/ASTContext.cpp:3071:0
...

Thats means there are two same FunctionProtoType objects in the set. So it
follows that we modify an object (and change hash) placed in the set.

I researched the issue placing a couple of breakpoints and found this:

A hash of FunctionProtoType depends on CanonicalDecl of ExceptionSpec
SourceDecl stored in ExtProtoInfo.
FunctionProtoType::Profile:
..
ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl())
..
But when clang create destructor(dtor) via clang::Sema::ActOnFunctionDeclarator
at lib/Sema/SemaDecl.cpp:7341 we use the created dtor as SourceDecl in
ExceptionSpec(in function Sema::AdjustDestructorExceptionSpec called
immediately after dtor creation) that results in creation new FunctionProtoType
because there cannot be a type in the set with just created dtor(without
previous decl) as set key. Later we call FunctionDecl::setPreviousDeclaration
for the dtor setting new canonical decl and changing the hash.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160530/84571fca/attachment.html>


More information about the llvm-bugs mailing list