[PATCH] D131009: [analyzer] Fixing a bug raising false positives of stack block object leaking under ARC

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 8 12:37:15 PDT 2022


NoQ added a comment.

Aha great, I see you've found that there's already an existing solution for this problem! I'm questioning this solution though, maybe a more general solution could have helped us avoid this problem altogether.



================
Comment at: clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp:313-315
+      // Under ARC, blocks are retained and released automatically:
+      if (isArcManagedBlock(Referred, Ctx))
+        return false;
----------------
Aha ok, it sounds like we can no longer be sure that the block is on the stack at this point, did I get it right?

In this case I think it's more productive to have the block's memory space be `UnknownSpaceRegion` from the start, so that it fell through the memory space check, both here and at other call sites of `isArcManagedBlock()` (so it can be removed), and in any other code that relies on memory spaces (so this mistake is never made again).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131009/new/

https://reviews.llvm.org/D131009



More information about the cfe-commits mailing list