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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to