[llvm-bugs] [Bug 31061] New: ASan failed to catch overrelease of block using Block_release

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 18 10:40:45 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=31061

            Bug ID: 31061
           Summary: ASan failed to catch overrelease of block using
                    Block_release
           Product: compiler-rt
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: compiler-rt
          Assignee: unassignedbugs at nondot.org
          Reporter: jordan_rose at apple.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Blocks, enabled by -fblocks, are a reference-counted data type once copied to
the heap using Block_copy; when compiling for Objective-C on Apple platforms
they are also valid Objective-C objects that respond to -copy, -retain, and
-release. ASan fails to catch the overrelease of a simple block copied to the
heap, as demonstrated by the following code.

---

// clang -fsanitize=address -fblocks

#include <stdio.h>
#include <Block.h>

int main(int argc, const char *argv[]) {
  __typeof(^{}) block = ^{ printf("%d\n", argc); };
  block = Block_copy(block);
  block();
  Block_release(block);
  Block_release(block); // overrelease
  // Note that the -release message and Block_release are interchangeable for
blocks.
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161118/d803d67c/attachment.html>


More information about the llvm-bugs mailing list