[llvm-bugs] [Bug 37838] New: Assertion triggered in clang::ento::GRBugReporter::generatePathDiagnostic

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 18 11:56:57 PDT 2018


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

            Bug ID: 37838
           Summary: Assertion triggered in
                    clang::ento::GRBugReporter::generatePathDiagnostic
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: v.reichelt at netcologne.de
                CC: llvm-bugs at lists.llvm.org

The following simple code snippet triggers an assertion in the analyzer
if GCC's standard library (with GCC version 7.1.0 or later) is used:

================================
#include <memory>

int foo()
{
  std::unique_ptr<int> a;
  int* p = a.release();
  return *p;
}
================================

GCCDIR=/GCC/gcc-7.1.0/include/c++/7.1.0
clang++ --analyze -I$GCCDIR -isystem $GCCDIR/x86_64-pc-linux-gnu -c bug.cc

clang-7: /LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2554:
virtual bool
clang::ento::GRBugReporter::generatePathDiagnostic(clang::ento::PathDiagnostic&,
clang::ento::PathDiagnosticConsumer&,
llvm::ArrayRef<clang::ento::BugReport*>&): Assertion `jj<10' failed.

The code can be reduced to the following code snippet:

================================
struct A
{
  int* p;
  A() : p() {}
};

int* g1(A& a) { return a.p; }
int* g2(A& a) { return g1(a); }
int* g3(A& a) { return g2(a); }
int* g4(A& a) { return g3(a); }
int* g5(A& a) { return g4(a); }
int* g6(A& a) { return g5(a); }
int* g7(A& a) { return g6(a); }
int* g8(A& a) { return g7(a); }

int foo()
{
  A a;
  int* p = g8(a);
  return *p;
}
================================

Apparently, the limit of 10 in the assertion is not enough.
This is a recent regression on trunk which happened between
r334351 and r334732.

Here's the relevant part of the stack trace:

#8 0x032f3a6b
clang::ento::GRBugReporter::generatePathDiagnostic(clang::ento::PathDiagnostic&,
clang::ento::PathDiagnosticConsumer&, llvm::ArrayRef<clang::ento::BugReport*>&)
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x32f3a6b)
#9 0x032ef757 clang::ento::BugReporter::FlushReport(clang::ento::BugReport*,
clang::ento::PathDiagnosticConsumer&, llvm::ArrayRef<clang::ento::BugReport*>)
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x32ef757)
#10 0x032f0831
clang::ento::BugReporter::FlushReport(clang::ento::BugReportEquivClass&)
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x32f0831)
#11 0x032f141f clang::ento::BugReporter::FlushReports()
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x32f141f)
#12 0x030d5a0a (anonymous
namespace)::AnalysisConsumer::ActionExprEngine(clang::Decl*, bool,
clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*,
llvm::DenseMapInfo<clang::Decl const*> >*) (.part.4930)
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x30d5a0a)
#13 0x030d61e4 (anonymous
namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int,
clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*,
llvm::DenseMapInfo<clang::Decl const*> >*)
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x30d61e4)
#14 0x030e39f7 (anonymous
namespace)::AnalysisConsumer::runAnalysisOnTranslationUnit(clang::ASTContext&)
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x30e39f7)
#15 0x030e419b (anonymous
namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&)
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x30e419b)
#16 0x033e7d12 clang::ParseAST(clang::Sema&, bool, bool)
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x33e7d12)
#17 0x0297eec6 clang::FrontendAction::Execute()
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x297eec6)
#18 0x02953b0e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x2953b0e)
#19 0x02a1b262 clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/LLVM/LLVM-trunk-334732/bin/clang-7+0x2a1b262)
#20 0x00c78d28 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/LLVM/LLVM-trunk-334732/bin/clang-7+0xc78d28)
#21 0x00c01c14 main (/LLVM/LLVM-trunk-334732/bin/clang-7+0xc01c14)

-- 
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/20180618/0a69da75/attachment.html>


More information about the llvm-bugs mailing list