<div dir="ltr">Hello,<div><br></div><div>you are probably seeing this behavior as a result of the maximum number of times a loop is unrolled during the symbolic execution of the program (by default, 4 times).</div><div><br>You can change the unroll limit with the following command line argument:</div><div><br></div><div><span style="color:rgb(92,93,94);font-family:"Source Sans Pro","Helvetica Neue",Helvetica,Arial,sans-serif;font-size:15px">clang -cc1 -analyze -analyzer-max-loop 100 -analyzer-checker=core [...]</span></div><div><span style="color:rgb(92,93,94);font-family:"Source Sans Pro","Helvetica Neue",Helvetica,Arial,sans-serif;font-size:15px"><br></span></div><div><font color="#5c5d5e" face="Source Sans Pro, Helvetica Neue, Helvetica, Arial, sans-serif"><span style="font-size:15px">The command above will change the unroll limit to 100 (however, you will probably see performance issues). The loop widening project (<a href="http://lists.llvm.org/pipermail/cfe-dev/2017-March/053060.html">http://lists.llvm.org/pipermail/cfe-dev/2017-March/053060.html</a>) might help with your issue once finished.</span></font><br><br><font color="#5c5d5e" face="Source Sans Pro, Helvetica Neue, Helvetica, Arial, sans-serif"><span style="font-size:15px">Best,</span></font><br><font color="#5c5d5e" face="Source Sans Pro, Helvetica Neue, Helvetica, Arial, sans-serif"><span style="font-size:15px">Stefan</span></font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 31, 2017 at 11:26 PM, Gupta Nikhil via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="#0563C1" vlink="#954F72"><div class="m_-9102420219292359359WordSection1"><p class="MsoNormal">Hi,<br><br>I have a trivial case where the Static Analyzer is not catching a double free bug:<br><br><u></u><u></u></p><p class="MsoNormal">==============<br> char *s;<u></u><u></u></p><p class="MsoNormal"> for(int i = 0; <b><u>i < 4</u></b>; i++)<u></u><u></u></p><p class="MsoNormal"> {<u></u><u></u></p><p class="MsoNormal"> s = (char*)malloc(10);<u></u><u></u></p><p class="MsoNormal"> free(s);<u></u><u></u></p><p class="MsoNormal"> }<u></u><u></u></p><p class="MsoNormal"> free(s);<u></u><u></u></p><p class="MsoNormal">================<u></u><u></u></p><p class="MsoNormal">However, if I change the code to:<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">==============<br> char *s;<u></u><u></u></p><p class="MsoNormal"> for(int i = 0; <b><u>i < 3</u></b>; i++)<u></u><u></u></p><p class="MsoNormal"> {<u></u><u></u></p><p class="MsoNormal"> s = (char*)malloc(10);<u></u><u></u></p><p class="MsoNormal"> free(s);<u></u><u></u></p><p class="MsoNormal"> }<u></u><u></u></p><p class="MsoNormal"> free(s);<u></u><u></u></p><p class="MsoNormal">================<u></u><u></u></p><p class="MsoNormal">A double free warning is thrown.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">On exploring this further, I noticed that the function MallocChecker::FreeMemAux is called no more than 4 times. Ie: I can place as many “free(s)” after the last one in the first code chunk and it will never be caught.<u></u><u></u></p><p class="MsoNormal">Its calling method MallocChecker::CheckPostStmt seems to be limited to being called a maximum of 8 times.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Is there a threshold set on the number of times a checker can be called? If so, can that be tweaked?<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Thanks in advance!<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Regards,<u></u><u></u></p><p class="MsoNormal">Nikhil<u></u><u></u></p></div></div><br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">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/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>