<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div>Hi,</div>
<div><br>
</div>
<div>My intuition is that in some situations it is guaranteed that the state will be modified and then the if (NewState!=State) check is unnecessary. In other situations there is a possibility that the state will remain the same (e.g. the expression was already
marked as tainted, so nothing changes) and this could theoretically create to a loop edge (an edge from the current node to itself) in the exploded graph.</div>
<div><br>
</div>
<div>A loop edge is obviously undesirable, because it could send graph traversal into infinite loops, so wee need to guarantee that they do not appear in the exploded graph. As Kristóf wrote, the method CheckerContext::addTransitionImpl() always guarantees
this with a defensive check (with a TODO to turn it into an assert); but in some checkers it is also tested by the checker itself.</div>
<div><br>
</div>
<div>Donát</div>
<div><br>
</div>
<div>On k, 2018-10-09 at 11:10 +0200, Kristóf Umann via cfe-dev wrote:</div>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div>Hi!<br>
<br>
</div>
<div>If you look at how <span style="font-family:monospace,monospace">addTransition</span> is implemented, you can see a big TODO before a defensive check:<br>
<a href="https://github.com/llvm-mirror/clang/blob/7c8e954f273730037b454edf94c8d13123dbedf6/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h#L289">https://github.com/llvm-mirror/clang/blob/7c8e954f273730037b454edf94c8d13123dbedf6/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h#L289</a><br>
</div>
<div>According to that, it would seem that a checker-side check should always be there.<br>
<br>
</div>
<div>Let's see what others think of this -- to me it would make more sense to have this check within
<span style="font-family:monospace,monospace">addTransition</span>, and I'm unsure myself why that TODO is there.<br>
</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">Lou Wynn via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> ezt írta (időpont: 2018. okt. 9., K, 3:42):<br>
</div>
<blockquote type="cite">
<div text="#000000" bgcolor="#FFFFFF">
<p><font size="+1">Hi,</font></p>
<p><font size="+1">I read the comment "avoid loops in the exploded graph" in the following snippet of code which is on page 32 of the
<a href="https://github.com/haoNoQ/clang-analyzer-guide/releases/download/v0.1/clang-analyzer-guide-v0.1.pdf" target="_blank">
workbook</a>.</font></p>
<p><tt><font size="+1">LocationContext *LC = C. getLocationContext (); <br>
ProgramStateRef State = C. getState (); <br>
const Expr *E = /* Obtain an expression value of which is untrusted */; <br>
ProgramStateRef NewState = State -> addTaint (E, LC ); <br>
if ( NewState != State ) // avoid loops in the exploded graph <br>
C. addTransition ( NewState );</font></tt></p>
<p><font size="+1">My question is why the new tainted state requires the if statement to prevent loops, while other new states in the book do not have the if statement when C.addTransition(State) is used? Do other states which are not tainted not need to prevent
loops? For example, on page 30, when a new state is added, it reads:</font></p>
<p><tt><font size="+1">ProgramStateRef State = C. getState (); <br>
State = modifyState ( State ); // do stuff <br>
C. addTransition ( State );</font></tt></p>
<p><font size="+1">There is no if state to prevent a loop.<br>
</font></p>
<pre class="m_4496106036804767320moz-signature" cols="72">--
Love,
Lou
</pre>
</div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote>
</div>
<pre>_______________________________________________
cfe-dev mailing list
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
</body>
</html>