<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Assertion triggered in clang::ento::GRBugReporter::generatePathDiagnostic"
href="https://bugs.llvm.org/show_bug.cgi?id=37838">37838</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Assertion triggered in clang::ento::GRBugReporter::generatePathDiagnostic
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Static Analyzer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>dcoughlin@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>v.reichelt@netcologne.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>