lsalamon / address-sanitizer

Automatically exported from code.google.com/p/address-sanitizer
0 stars 1 forks source link

Using Obj-C blocks triggers a false-positive ODR violation #360

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
On OS X top-of-tree Clang+AddressSanitizer, the following produces a false 
positive ODR violation during initialization:

    void f() {
        int y = 7;
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
            dispatch_sync(dispatch_get_main_queue(), ^{
                printf("num = %d\n", y);
            });
        });
    }

    =================================================================
    ==98053==ERROR: AddressSanitizer: odr-violation (0x00010cb4ae20):
      [1] size=1 'OBJC_CLASS_NAME_2' /tmp/llvm/projects/compiler-rt/test/asan/TestCases/Darwin/objc-odr.mm
      [2] size=1 'OBJC_CLASS_NAME_' /tmp/llvm/projects/compiler-rt/test/asan/TestCases/Darwin/objc-odr.mm
    These globals were registered at these points:
      [1]:
        #0 0x10cb5989c  (/tmp/llvm-cmake-debug/lib/clang/3.6.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib+0x889c)
        #1 0x10cb4ac2b  (/tmp/llvm-cmake-debug/projects/compiler-rt/test/asan/64bitConfig/TestCases/Darwin/Output/objc-odr.mm.tmp+0x100001c2b)
        #2 0x7fff67e5acea  (<unknown module>)
        #3 0x7fff67e5ae77  (<unknown module>)
      ...

Apparently, something changed in the way Obj-C globals are generated or 
instrumented. See the attached test case.

Original issue reported on code.google.com by kuba.brecka@gmail.com on 2 Dec 2014 at 8:09

Attachments:

GoogleCodeExporter commented 9 years ago
This is now fixed with http://reviews.llvm.org/D6488 and r223513 and r223514.

Original comment by kuba.brecka@gmail.com on 9 Dec 2014 at 9:30

GoogleCodeExporter commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Original comment by ramosian.glider@gmail.com on 30 Jul 2015 at 9:14