<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">My understanding is that this is in the “unix” package for historical reasons from before the analyzer thought about Windows. We have clients that rely on the malloc checker being enabled/disabled with ‘unix.Malloc' so moving it will break compatibility. <div class=""><br class=""></div><div class="">I discussed this off-list with Anna Zaks. She recommended changing the driver to enable unix.Malloc explicitly when running in a Windows MSVC environment. This is Clang::ConstructJob() in Tools.cpp. We currently skip enabling the “unix” package there for Windows MSVC.</div><div class=""><br class=""></div><div class="">Someone who develops on Windows should write a patch and test it. Alexander: would you be willing to do this? It should be very straightforward — there is similar code to disable specific checkers for PS4.</div><div class=""><br class=""></div><div class="">We should also add a comment Checkers.td to indicate that we should move the Malloc checker to another package when we do remap packages names and break backward compatibility. “core” is probably not the right place for this (since malloc() is in the standard library). Maybe a new “cstdlib” package?</div><div class=""><br class=""></div><div class="">Devin</div><div class=""><div class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 12, 2016, at 2:22 PM, Alexander Riccio via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div class=""><div class=""><div style="font-family: Calibri,sans-serif; font-size: 11pt;" class="">Shoot - I haven't responded to this. I did some debugging the other day and found that if I manually pass the flag to enable the unix.Malloc checker (that's a capital "M", as I discovered the hard way), Clang detects this.<br class=""><br class="">I was going to suggest something like enabling it by default (obvious), and *maybe* renaming it to something like core.Malloc, because it's not unix-specific.<br class=""><br class="">The one benefit here of parsing SAL is a more generic mechanism, but that's a different issue.<br class=""><br class="">sent from my (stupid) windows phone</div></div><div dir="ltr" class=""><hr class=""><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;" class="">From: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;" class=""><a href="mailto:rnk@google.com" class="">Reid Kleckner</a></span><br class=""><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;" class="">Sent: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;" class="">1/12/2016 5:18 PM</span><br class=""><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;" class="">To: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;" class=""><a href="mailto:test35965@gmail.com" class=""><Alexander G. Riccio></a>; <a href="mailto:jordan_rose@apple.com" class="">Jordan Rose</a></span><br class=""><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;" class="">Cc: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;" class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev</a></span><br class=""><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;" class="">Subject: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;" class="">Re: [cfe-dev] Clang on Windows fails to detect trivial double free instatic analysis</span><br class=""><br class=""></div><div dir="ltr" class="">Jordan, how do we enable this checker on Windows?<div class=""><br class=""></div><div class="">We shouldn't need to be able to parse SAL to do this analysis.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Jan 3, 2016 at 10:31 PM, <Alexander G. Riccio> via cfe-dev <span dir="ltr" class=""><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div dir="ltr" class="">Is it because <a href="http://clang-analyzer.llvm.org/available_checks.html#unix_checkers" target="_blank" class="">the checker is <i class=""><b class=""><u class="">unix</u></b></i>.malloc</a>? If so, that's actually quite terrible... why only check it on unix??</div><div class="gmail_extra"><span class=""><br clear="all" class=""><div class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><span style="font-size: 12.8px;" class="">Sincerely,</span><br style="font-size: 12.8px;" class=""><span style="font-size: 12.8px;" class="">Alexander Riccio</span><br style="font-size: 12.8px;" class=""><span style="font-size: 12.8px;" class="">--</span><br style="font-size: 12.8px;" class=""><span style="font-size: 12.8px;" class="">"Change the world or go home."</span><div style="font-size: 12.8px;" class=""><a href="http://about.me/ariccio" target="_blank" class="">about.me/ariccio</a></div><div style="font-size: 12.8px;" class=""><a href="http://about.me/ariccio" target="_blank" class=""><br class=""></a></div><div style="font-size: 12.8px;" class="">If left to my own devices, I will build more.</div><div style="font-size: 12.8px;" class="">⁂</div></div></div></div></div></div>
<br class=""></span><div class=""><div class="h5"><div class="gmail_quote">On Sat, Jan 2, 2016 at 3:57 PM, <Alexander G. Riccio> <span dir="ltr" class=""><<a href="mailto:test35965@gmail.com" target="_blank" class="">test35965@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div dir="ltr" class="">When I build the attached C program in windows, using Clang built from a very recent tree version (trunk 256686), Clang fails to detect the trivial double free, as evidenced in the resulting plist file (attached).<div class=""><br class=""></div><div class="">What's going on here? I have a gut feeling that it has something to do with Clang's ignorance of SAL, which allows MSVC to detect the condition generically:</div><div class=""><br class=""></div><div class=""><pre style="background: rgb(30, 30, 30); color: gainsboro; font-family: Consolas;" class=""><span style="color: rgb(86, 156, 214);" class="">void</span> <span style="color: rgb(86, 156, 214);" class="">__cdecl</span> <span style="color: rgb(200, 200, 200);" class="">free</span><span style="color: rgb(180, 180, 180);" class="">(</span>
<span style="color: rgb(189, 99, 197);" class="">_Pre_maybenull_</span> <span style="color: rgb(189, 99, 197);" class="">_Post_invalid_</span> <span style="color: rgb(86, 156, 214);" class="">void</span><span style="color: rgb(180, 180, 180);" class="">*</span> _Block
<span style="color: rgb(180, 180, 180);" class="">);</span>
</pre></div><div class="">(from C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt/corecrt_malloc.h)</div><div class=""><br class=""></div><div class="">I'm also attaching the verbose compilation output.</div><div class=""><div class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><span style="font-size: 12.8px;" class=""><br class=""></span></div><div dir="ltr" class=""><span style="font-size: 12.8px;" class="">Sincerely,</span><br style="font-size: 12.8px;" class=""><span style="font-size: 12.8px;" class="">Alexander Riccio</span><br style="font-size: 12.8px;" class=""><span style="font-size: 12.8px;" class="">--</span><br style="font-size: 12.8px;" class=""><span style="font-size: 12.8px;" class="">"Change the world or go home."</span><div style="font-size: 12.8px;" class=""><a href="http://about.me/ariccio" target="_blank" class="">about.me/ariccio</a></div><div style="font-size: 12.8px;" class=""><a href="http://about.me/ariccio" target="_blank" class=""><br class=""></a></div><div style="font-size: 12.8px;" class="">If left to my own devices, I will build more.</div><div style="font-size: 12.8px;" class="">⁂</div></div></div></div></div></div>
</div></div>
</blockquote></div><br class=""></div></div></div>
<br class="">_______________________________________________<br class="">
cfe-dev mailing list<br class="">
<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank" rel="noreferrer" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div>_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></div></div></div></body></html>