<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Dec 3, 2011, at 10:48 PM, Anna Zaks wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div><blockquote type="cite">E.g. I would expect that even in the purely intraprocedural case it<br></blockquote><blockquote type="cite">could catch something like this:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">int *foo, *bar;<br></blockquote><blockquote type="cite">int baz = something;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">foo = (int*) malloc(CONSTANT * sizeof(int));<br></blockquote><blockquote type="cite">bar = (foo + CONSTANT + 1);<br></blockquote><blockquote type="cite">*bar = baz;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">, which the present implementation of 'ArrayBoundV2' does not catch.<br></blockquote><br>This example is not handled because the checker does not reason about malloc. Note, the analyzer CAN find the bug in the following example:<br><br>void m() {<br>   int foo[3];<br>   int *bar;<br>   bar = (foo + 3 + 1);<br>   *bar = 3;<br>}</div></span></blockquote></div><br><div>The way I'd like to see this generally approached is that ArrayBoundV2 could consult some API to check the "known bound" for a region.  We have a mechanism, known as "extents".  Specific checkers could register their knowledge of extents (e.g., the Malloc checker could register an extent for malloc'ed memory) and ArrayBoundCheckerV2 just cues off that extent information.</div><div><br></div><div>I'm interested in a general, scalable solution for adding such information.  In the short term, that could be added to ArrayBoundCheckerV2 as a post-visit on CallExprs.  This would leave the current bounds checking logic to just consult the generic extent information in the ProgramState.</div><div><br></div><div>More generally, I'd like any checker be able to register information about extents, and then have the ArrayBoundCheckerV2 automatically get smarter by leveraging such domain-specific information.  Further, once IPA comes available, we may be able to infer this extent information by other means.</div></body></html>