[PATCH] D34772: Treat allocations within dispatch_once blocks as global allocations

Francis Ricci via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 28 12:38:55 PDT 2017


fjricci created this revision.

Objective-C programs often treat dispatch_once blocks similarly to global
variables, since they are only executed once over the course of the process.
They are often used to initialize singletons and other process state.

For an example of a simple test case which reveals this behavior in darwin system
libraries:

  // clang -fsanitize=leak -framework Foundation test.m
  #import <Foundation/Foundation.h>
  
  int main() {
      @autoreleasepool { id defaults = [NSUserDefaults standardUserDefaults]; };
      return 0;
  }

This patch treats dispatch_once allocations as global variables, ignoring
them if use_globals is enabled.


https://reviews.llvm.org/D34772

Files:
  lib/asan/asan_mac.cc
  lib/lsan/lsan_mac.cc
  test/lsan/TestCases/Darwin/blocks.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34772.104493.patch
Type: text/x-patch
Size: 7594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170628/01f40f58/attachment.bin>


More information about the llvm-commits mailing list