<div dir="ltr"><div>Hello guys,<br><br></div><div>And thanks for your attention<br></div><div><br></div><div>Aleksei,<br><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Could you share your ideas of checker design? It is possible that
      problems you met can be solved in different (maybe even better)
      way if we know the whole picture.<br></blockquote><br></div>As I 
said, I'm interested in improving current state of dynamic memory 
modeling. Especially stuff related to smart pointers (e.g. shared, 
unique) which also mentioned in list of potential checkers as <a href="https://clang-analyzer.llvm.org/potential_checkers.html" target="_blank"><span class="gmail-m_2955499014588667344gmail-name">smartptr.SmartPtrInit</span></a><b><span class="gmail-m_2955499014588667344gmail-lang"><br><br></span></b><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><b> </b>You can see an example of how state trait is
      exported in GenericTaintChecker or MPIChecker. Generally, you just
      create a named ProgramStateTrait in the header. <br></blockquote><div><br></div><div>Briefly looked at MPITypes.h. Does it mean we should move RegionState to separate file and register it via Traits in the same manner to make it avaliable from other checkers (not other TU as mentioned in ento::mpi::RequestMap)?<br><br></div><div>Artem,<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">you need to keep all of this in mind when writing a checker.<br></blockquote><div><br></div><div>Sure, but on the other hand I think it's possible to implement and improve modeling of various API calls' effects step-by-step. Let's say, it case of SmartPtrInit checker mentioned before the bare minimum would be modeling of construction (and destruction to avoid leak report from existing related checkers).<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">which is why the few experimental C++ checkers that we currently have 
required heavy hacks to become possible. But for now you'd rather keep 
an eye on these problems.<span class="gmail-im"><br></span></blockquote><div><br></div><div>Does it mean it's better to wait a bit for Core improvements from main contributors? Does it make sense to make an efforts to implement SmartPtrItnit checker in current state of things?<br><br></div><div>Thanks in advance and regards,<br></div><div>Alexey K<br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-03-16 21:47 GMT+03:00 Artem Dergachev <span dir="ltr"><<a href="mailto:noqnoqneo@gmail.com" target="_blank">noqnoqneo@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dynamic memory management is pretty much done at this point - we have very good support for malloc()-like stuff and reasonably good support for operator new() (support for operator new[]() is currently missing because it requires calling an indefinite number of constructors which is not yet implemented). There is also a known issue with custom operator new(...) returning null pointers - in this case we should not be calling the constructor but for now we evaluate the constructor conservatively.<br>
<br>
Your real problem will be managing smart pointers themselves because they are C++ objects that have a myriad of methods, they can be copied, moved, assigned, move-assigned, they destroyed, they lifetime-extended, you need to keep all of this in mind when writing a checker. This is slowly getting easier because i'm currently working on that, but until recently it wasn't working correctly in the core, let alone checkers, which is why the few experimental C++ checkers that we currently have required heavy hacks to become possible. But for now you'd rather keep an eye on these problems.<span class=""><br>
<br>
On 16/03/2018 3:57 AM, Aleksei Sidorin via cfe-dev wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
Hi Alexey!<br>
<br>
Could you share your ideas of checker design? It is possible that problems you met can be solved in different (maybe even better) way if we know the whole picture.<br>
Regarding your questions, you can find some answers below.<br>
<br>
1. a) The first way for checker communication is to share their program state trait. You can see an example of how state trait is exported in GenericTaintChecker or MPIChecker. Generally, you just create a named ProgramStateTrait in the header. You can take a look at TaintManager.h and MPITypes.h and how they are used.<br>
b) To set a dependency from another checker, you can just register it while registering your checker. An example can be found in MallocChecker where register$Checker also calls registerCStringCheckerBasic to register a checker it depends on.<br>
As you pointed, inter-checker communication can become a source of some problems. Most of them are discussed in this conversation: <a href="http://clang-developers.42468.n3.nabble.com/analyzer-RFC-Design-idea-separate-modelling-from-checking-td4059122.html" rel="noreferrer" target="_blank">http://clang-developers.42468.<wbr>n3.nabble.com/analyzer-RFC-Des<wbr>ign-idea-separate-modelling-<wbr>from-checking-td4059122.html</a><br>
<br>
2. I think there is nothing bad in sharing RegionState across checkers in the way shown in 1a.<br>
<br>
3. Artem Dergachev has done some excellent work on improvement of operator 'new' processing in CSA engine. Regarding checkers, I can see some on <a href="https://clang-analyzer.llvm.org/potential_checkers.html" rel="noreferrer" target="_blank">https://clang-analyzer.llvm.or<wbr>g/potential_checkers.html</a>: for example, undefbehavior.AutoptrsOwnSameO<wbr>bj. You can search this list to find more.<br>
<br>
<br>
15.03.2018 23:54, Alexey Knyshev via cfe-dev пишет:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
Hi there!<br>
<br>
While thinking about how it would be possible to implement various smart ptr related checkers I tried to review current state of MallocChecker and came up with that it would be great to have RegionState info available to other checkers. Could you please share your points of view and comments on the following statements / questions:<br>
<br>
1. Is there any right way for chaining checkers? How they are expected to communicate between each other (excluding generation of nodes / ProgramStates). I've heard that there are couple of problems caused by inlining functions, constructors / descructors.<br>
2. What do you think about moving RegionState to the Core of CSA or providing optional extended info in MemRegion about the source of such region (new opearator / array new, malloc, alloca, etc). So it would be available to all checkers.<br>
3. Is there any roadmap for CSA and especially for dynamic memory management modeling & related checkers?<br>
<br>
Regards, Alexey K<br>
<br>
-- <br>
</span><a href="http://linkedin.com/profile" rel="noreferrer" target="_blank">linkedin.com/profile</a> <<a href="https://www.linkedin.com/profile/view?id=AAMAABn6oKQBDhBteiQnWsYm-S9yxT7wQkfWhSw" rel="noreferrer" target="_blank">https://www.linkedin.com/prof<wbr>ile/view?id=AAMAABn6oKQBDhBtei<wbr>QnWsYm-S9yxT7wQkfWhSw</a>><br>
<br>
<a href="http://github.com/alexeyknyshev" rel="noreferrer" target="_blank">github.com/alexeyknyshev</a> <<a href="http://github.com/alexeyknyshev" rel="noreferrer" target="_blank">http://github.com/alexeyknysh<wbr>ev</a>><br>
<a href="http://bitbucket.org/alexeyknyshev" rel="noreferrer" target="_blank">bitbucket.org/alexeyknyshev</a> <<a href="https://bitbucket.org/alexeyknyshev/" rel="noreferrer" target="_blank">https://bitbucket.org/alexeyk<wbr>nyshev/</a>><span class=""><br>
<br>
<br>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/cfe-dev</a><br>
</span></blockquote><span class="">
<br>
<br>
-- <br>
Best regards,<br>
Aleksei Sidorin,<br>
SRR, Samsung Electronics<br>
<br>
<br>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/cfe-dev</a><br>
</span></blockquote>
<br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><a href="https://www.linkedin.com/profile/view?id=AAMAABn6oKQBDhBteiQnWsYm-S9yxT7wQkfWhSw" target="_blank">linkedin.com/profile</a><br><br><a href="http://github.com/alexeyknyshev" target="_blank">github.com/alexeyknyshev</a><span></span><a href="http:///" target="_blank"></a><span></span><br><a href="https://bitbucket.org/alexeyknyshev/" target="_blank">bitbucket.org/alexeyknyshev</a><br></div></div>
</div>