Skip to content
  1. Nov 27, 2012
  2. Nov 19, 2012
  3. Nov 15, 2012
    • Jordan Rose's avatar
      [analyzer] Report leaks at the closing brace of a function body. · e37ab50a
      Jordan Rose authored
      This fixes a few cases where we'd emit path notes like this:
      
        +---+
       1|   v
        p = malloc(len);
        ^   |2
        +---+
      
      In general this should make path notes more consistent and more correct,
      especially in cases where the leak happens on the false branch of an if
      that jumps directly to the end of the function. There are a couple places
      where the leak is reported farther away from the cause; these are usually
      cases where there are several levels of nested braces before the end of
      the function. This still matches our current behavior for when there /is/
      a statement after all the braces, though.
      
      llvm-svn: 168070
      e37ab50a
    • Jordan Rose's avatar
      [analyzer] Mark symbol values as dead in the environment. · b5b0fc19
      Jordan Rose authored
      This allows us to properly remove dead bindings at the end of the top-level
      stack frame, using the ReturnStmt, if there is one, to keep the return value
      live. This in turn removes the need for a check::EndPath callback in leak
      checkers.
      
      This does cause some changes in the path notes for leak checkers. Previously,
      a leak would be reported at the location of the closing brace in a function.
      Now, it gets reported at the last statement. This matches the way leaks are
      currently reported for inlined functions, but is less than ideal for both.
      
      llvm-svn: 168066
      b5b0fc19
  4. Sep 13, 2012
  5. Sep 12, 2012
    • Chandler Carruth's avatar
      Adjust some analyzer tests to place widely shared inputs inside of an · 66a34a6a
      Chandler Carruth authored
      'Inputs' subdirectory.
      
      The general desire has been to have essentially all of the non-test
      input files live in such directories, with some exceptions for obvious
      and common patterns like 'foo.c' using 'foo.h'.
      
      This came up because our distributed test runner couldn't find some of
      the headers, for example with stl.cpp.
      
      No functionality changed, just shuffling around here.
      
      llvm-svn: 163674
      66a34a6a
  6. Aug 24, 2012
  7. Aug 16, 2012
    • Ted Kremenek's avatar
      Allow multiple PathDiagnosticConsumers to be used with a BugReporter at the same time. · 9bf9af92
      Ted Kremenek authored
      This fixes several issues:
      
      - removes egregious hack where PlistDiagnosticConsumer would forward to HTMLDiagnosticConsumer,
      but diagnostics wouldn't be generated consistently in the same way if PlistDiagnosticConsumer
      was used by itself.
      
      - emitting diagnostics to the terminal (using clang's diagnostic machinery) is no longer a special
      case, just another PathDiagnosticConsumer.  This also magically resolved some duplicate warnings,
      as we now use PathDiagnosticConsumer's diagnostic pruning, which has scope for the entire translation
      unit, not just the scope of a BugReporter (which is limited to a particular ExprEngine).
      
      As an interesting side-effect, diagnostics emitted to the terminal also have their trailing "." stripped,
      just like with diagnostics emitted to plists and HTML.  This required some tests to be updated, but now
      the tests have higher fidelity with what users will see.
      
      There are some inefficiencies in this patch.  We currently generate the report graph (from the ExplodedGraph)
      once per PathDiagnosticConsumer, which is a bit wasteful, but that could be pulled up higher in the
      logic stack.  There is some intended duplication, however, as we now generate different PathDiagnostics (for the same issue)
      for different PathDiagnosticConsumers.  This is necessary to produce the diagnostics that a particular
      consumer expects.
      
      llvm-svn: 162028
      9bf9af92
  8. Aug 08, 2012
    • Jordan Rose's avatar
      [analyzer] Clean up the printing of FieldRegions for leaks. · d86b3bdb
      Jordan Rose authored
      Unfortunately, generalized region printing is very difficult:
      - ElementRegions are used both for casting and as actual elements.
      - Accessing values through a pointer means going through an intermediate
        SymbolRegionValue; symbolic regions are untyped.
      - Referring to implicitly-defined variables like 'this' and 'self' could be
        very confusing if they come from another stack frame.
      
      We fall back to simply not printing the region name if we can't be sure it
      will print well. This will allow us to improve in the future.
      
      llvm-svn: 161512
      d86b3bdb
    • Jordan Rose's avatar
      [analyzer] Track malloc'd regions stored in structs. · 356279ca
      Jordan Rose authored
      The main blocker on this (besides the previous commit) was that
      ScanReachableSymbols was not looking through LazyCompoundVals.
      Once that was fixed, it's easy enough to clear out malloc data on return,
      just like we do when we bind to a global region.
      
      <rdar://problem/10872635>
      
      llvm-svn: 161511
      356279ca
  9. Aug 04, 2012
  10. Aug 03, 2012
    • Anna Zaks's avatar
      [analyzer] Malloc: track non-allocated but freed memory · 52242a66
      Anna Zaks authored
      There is no reason why we should not track the memory which was not
      allocated in the current function, but was freed there. This would
      allow to catch more use-after-free and double free with no/limited IPA.
      
      Also fix a realloc issue which surfaced as the result of this patch.
      
      llvm-svn: 161248
      52242a66
  11. Jul 02, 2012
    • Jordan Rose's avatar
      [analyzer] Move the last bits of CallOrObjCMessage over to CallEvent. · 7ab0182e
      Jordan Rose authored
      This involved refactoring some common pointer-escapes code onto CallEvent,
      then having MallocChecker use those callbacks for whether or not to consider
      a pointer's /ownership/ as escaping. This still needs to be pinned down, and
      probably we want to make the new argumentsMayEscape() function a little more
      discerning (content invalidation vs. ownership/metadata invalidation), but
      this is a good improvement.
      
      As a bonus, also remove CallOrObjCMessage from the source completely.
      
      llvm-svn: 159557
      7ab0182e
  12. Jun 21, 2012
  13. Jun 16, 2012
    • Jordan Rose's avatar
      [analyzer] Buffers passed to CGBitmapContextCreate can escape. · de409b6d
      Jordan Rose authored
      Specifically, although the bitmap context does not take ownership of the
      buffer (unlike CGBitmapContextCreateWithData), the data buffer can be extracted
      out of the created CGContextRef. Thus the buffer is not leaked even if its
      original pointer goes out of scope, as long as
      - the context escapes, or
      - it is retrieved via CGBitmapContextGetData and freed.
      
      Actually implementing that logic is beyond the current scope of MallocChecker,
      so for now CGBitmapContextCreate goes on our system function exception list.
      
      llvm-svn: 158579
      de409b6d
  14. Jun 08, 2012
  15. Jun 07, 2012
    • Anna Zaks's avatar
      [analyzer] Fixit for r158136. · a7dcc996
      Anna Zaks authored
      I falsely assumed that the memory spaces are equal when we reach this
      point, they might not be when memory space of one or more is stack or
      Unknown. We don't want a region from Heap space alias something with
      another memory space.
      
      llvm-svn: 158165
      a7dcc996
    • Anna Zaks's avatar
      [analyzer] Anti-aliasing: different heap allocations do not alias · 3563fde6
      Anna Zaks authored
      Add a concept of symbolic memory region belonging to heap memory space.
      When comparing symbolic regions allocated on the heap, assume that they
      do not alias. 
      
      Use symbolic heap region to suppress a common false positive pattern in
      the malloc checker, in code that relies on malloc not returning the
      memory aliased to other malloc allocations, stack.
      
      llvm-svn: 158136
      3563fde6
  16. May 18, 2012
  17. May 04, 2012
  18. May 03, 2012
    • Anna Zaks's avatar
      [analyzer] Conjure a symbol to ensure we can identify pointer arithmetic · 1655aee1
      Anna Zaks authored
      We need to identify the value of ptr as
      ElementRegion (result of pointer arithmetic) in the following code.
      However, before this commit '(2-x)' evaluated to Unknown value, and as
      the result, 'p + (2-x)' evaluated to Unknown value as well.
      
      int *p = malloc(sizeof(int));
      ptr = p + (2-x);
      
      llvm-svn: 156052
      1655aee1
    • Anna Zaks's avatar
      [analyzer] Revert the functional part of r155944. · 7124b4b1
      Anna Zaks authored
      The change resulted in multiple issues on the buildbot, so it's not
      ready for prime time. Only enable history tracking for tainted
      data(which is experimental) for now.
      
      llvm-svn: 156049
      7124b4b1
  19. May 02, 2012
  20. May 01, 2012
  21. Apr 26, 2012
  22. Mar 21, 2012
    • Anna Zaks's avatar
      [analyzer] Malloc: Utter the name of the leaked variable. · fc2e1534
      Anna Zaks authored
      Specifically, we use the last store of the leaked symbol in the leak diagnostic.
      (No support for struct fields since the malloc checker doesn't track those
      yet.)
      
      + Infrastructure to track the regions used in store evaluations.
      This approach is more precise than iterating the store to
      obtain the region bound to the symbol, which is used in RetainCount
      checker. The region corresponds to what is uttered in the code in the
      last store and we do not rely on the store implementation to support
      this functionality.
      
      llvm-svn: 153212
      fc2e1534
  23. Mar 06, 2012
  24. Feb 29, 2012
    • Anna Zaks's avatar
      [analyzer] Malloc: A pointer might escape through CFContainers APIs, · e0c03cab
      Anna Zaks authored
      funopen, setvbuf.
      
      Teach the checker and the engine about these APIs to resolve malloc
      false positives. As I am adding more of these APIs, it is clear that all
      this should be factored out into a separate callback (for example,
      region escapes). Malloc, KeyChainAPI and RetainRelease checkers could
      all use it.
      
      llvm-svn: 151737
      e0c03cab
  25. Feb 23, 2012
    • Anna Zaks's avatar
      [analyzer] Malloc: unique leak reports by allocation site. · df901a44
      Anna Zaks authored
      When we find two leak reports with the same allocation site, report only
      one of them.
      
      Provide a helper method to BugReporter to facilitate this.
      
      llvm-svn: 151287
      df901a44
    • Anna Zaks's avatar
      [analyzer] Invalidate the region passed to pthread_setspecific() call. · 07de9c12
      Anna Zaks authored
      Make this call an exception in ExprEngine::invalidateArguments:
      'int pthread_setspecific(ptheread_key k, const void *)' stores
      a value into thread local storage. The value can later be retrieved
      with 'void *ptheread_getspecific(pthread_key)'. So even thought the
      parameter is 'const void *', the region escapes through the
      call.
      
      (Here we just blacklist the call in the ExprEngine's default
      logic. Another option would be to add a checker which evaluates
      the call and triggers the call to invalidate regions.)
      
      Teach the Malloc Checker, which treats all system calls as safe about
      the API.
      
      llvm-svn: 151220
      07de9c12
  26. Feb 22, 2012
  27. Feb 20, 2012
    • Anna Zaks's avatar
      [analyzer] Turn on by default the Malloc Checker and a couple of CString · 0cdce4df
      Anna Zaks authored
      checks:
      
      - unix.Malloc - Checks for memory leaks, double free, use-after-free.
      - unix.cstring.NullArg - Checks for null pointers passed as arguments to
      CString functions + evaluates CString functions.
      - unix.cstring.BadSizeArg - Checks for common anti-patterns in
      strncat size argument.
      
      llvm-svn: 150988
      0cdce4df
  28. Feb 17, 2012
Loading