<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.hoenzb
{mso-style-name:hoenzb;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Karthik,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>You are right. This is basically the reason I got the error.<o:p></o:p></span></p><p class=MsoNormal>--- lib/StaticAnalyzer/Core/MemRegion.cpp (revision 190992)<o:p></o:p></p><p class=MsoNormal>+++ lib/StaticAnalyzer/Core/MemRegion.cpp (working copy)<o:p></o:p></p><p class=MsoNormal>@@ -1244,6 +1244,7 @@<o:p></o:p></p><p class=MsoNormal> if (!Child) {<o:p></o:p></p><p class=MsoNormal> // We cannot compute the offset of the base class.<o:p></o:p></p><p class=MsoNormal> SymbolicOffsetBase = R;<o:p></o:p></p><p class=MsoNormal>+ continue;<o:p></o:p></p><p class=MsoNormal> }<span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>In addition to what you have suggested, I think we should also return false (in MemRegion.cpp:isImmediateBase), or may be assert when the Child pointer is NULL.<o:p></o:p></span></p><p class=MsoNormal>@file: MemRegion.cpp<br>static bool isImmediateBase(const CXXRecordDecl *Child,<br> const CXXRecordDecl *Base) {<br><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>+ if (!Child)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>+ return false;<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Karthik Bhat [mailto:blitz.opensource@gmail.com] <br><b>Sent:</b> Friday, September 20, 2013 12:01 AM<br><b>To:</b> Jordan Rose<br><b>Cc:</b> Aditya Kumar; Clang Dev<br><b>Subject:</b> Re: [cfe-dev] [StaticAnalyzer] Potential bug in MemRegion.cpp?<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>I'm not sure of the test case but the problem seems to be in MemRegion::getAsOffset(). <o:p></o:p></p><div><p class=MsoNormal>In switch case case CXXBaseObjectRegionKind:<o:p></o:p></p><div><p class=MsoNormal>if we cannot compute the offset of the base class we need to continue in the loop instead of moving further down-<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><div><p class=MsoNormal>Index: lib/StaticAnalyzer/Core/MemRegion.cpp<o:p></o:p></p></div><div><p class=MsoNormal>===================================================================<o:p></o:p></p></div><div><p class=MsoNormal>--- lib/StaticAnalyzer/Core/MemRegion.cpp (revision 190992)<o:p></o:p></p></div><div><p class=MsoNormal>+++ lib/StaticAnalyzer/Core/MemRegion.cpp (working copy)<o:p></o:p></p></div><div><p class=MsoNormal>@@ -1244,6 +1244,7 @@<o:p></o:p></p></div><div><p class=MsoNormal> if (!Child) {<o:p></o:p></p></div><div><p class=MsoNormal> // We cannot compute the offset of the base class.<o:p></o:p></p></div><div><p class=MsoNormal> SymbolicOffsetBase = R;<o:p></o:p></p></div><div><p class=MsoNormal>+ continue;<o:p></o:p></p></div><div><p class=MsoNormal> }<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal> if (RootIsSymbolic) {<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>What do you think Jordan?<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Regards<o:p></o:p></p></div><div><p class=MsoNormal>Karthik Bhat<o:p></o:p></p></div></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p><div><p class=MsoNormal>On Fri, Sep 20, 2013 at 5:51 AM, Jordan Rose <<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>> wrote:<o:p></o:p></p><p class=MsoNormal>If it's not a private program you can create a bug at <a href="http://llvm.org/bugs/" target="_blank">http://llvm.org/bugs/</a> and attach the preprocessed file. If it is a private program (corporate or something) well...you could at least report where the caller is and what the original MemRegion is (using MemRegion::dump) and I can try to figure it out from that.<br><span style='color:#888888'><br><span class=hoenzb>Jordan</span></span><o:p></o:p></p><div><div><p class=MsoNormal><br><br>On Sep 19, 2013, at 17:15 , Aditya Kumar <<a href="mailto:hiraditya@codeaurora.org">hiraditya@codeaurora.org</a>> wrote:<br><br>> I was compiling a program when I hit this segmentation fault. The program is<br>> kind of big and I don't know how to reduce it to a minimal test case.<br>><br>><br>><br>>> -----Original Message-----<br>>> From: Jordan Rose [mailto:<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>]<br>>> Sent: Thursday, September 19, 2013 11:13 AM<br>>> To: Aditya Kumar<br>>> Cc: 'Clang Dev'<br>>> Subject: Re: [cfe-dev] [StaticAnalyzer] Potential bug in MemRegion.cpp?<br>>><br>>> I think the bug here is that "Child" should never be NULL. How are you<br>>> getting into this situation?<br>>><br>>> Jordan<br>>><br>>> On Sep 19, 2013, at 8:15 , Aditya Kumar <<a href="mailto:hiraditya@codeaurora.org">hiraditya@codeaurora.org</a>> wrote:<br>>><br>>>> When the following function is called by (RegionOffset<br>>>> MemRegion::getAsOffset() const:1257), and the first parameter (Child)<br>>>> is a NULL pointer I get a segmentation fault.<br>>>><br>>>> @file: MemRegion.cpp<br>>>> 01164 static bool isImmediateBase(const CXXRecordDecl *Child,<br>>>> 01165 const CXXRecordDecl *Base) {<br>>>> 01166 // Note that we do NOT canonicalize the base class here, because<br>>>> 01167 // ASTRecordLayout doesn't either. If that leads us down the<br>> wrong<br>>>> path,<br>>>> 01168 // so be it; at least we won't crash.<br>>>> 01169 for (CXXRecordDecl::base_class_const_iterator I =<br>>>> Child->bases_begin(),<br>>>> 01170 E =<br>>>> Child->bases_end();<br>>>> 01171 I != E; ++I) {<br>>>> 01172 if (I->getType()->getAsCXXRecordDecl() == Base)<br>>>> 01173 return true;<br>>>> 01174 }<br>>>> 01175<br>>>> 01176 return false;<br>>>> 01177 }<br>>>><br>>>> For now I just return `false' when `Child' pointer is NULL. Is this<br>>>> fix okay or there is something else required to be done?<br>>>><br>>>><br>>>> Thanks,<br>>>> -Aditya<br>>>><br>>>><br>>>> _______________________________________________<br>>>> cfe-dev mailing list<br>>>> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>>>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>><br>><br><br>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><o:p></o:p></p></div></div></div><p class=MsoNormal><o:p> </o:p></p></div></div></div></body></html>