[compiler-rt] r175631 - [ASan] Delete asan/dynamic dir and temporarily move the interposers declarations to asan_intercepted_functions.h

Alexander Potapenko glider at google.com
Wed Feb 20 11:28:22 PST 2013


This has obviously been caused by the change to asan_test.cc (I've
made it crash the main process instead of the forked one).
I'll revert this file once I get to work (tomorrow noon), or you can
do that if you prefer.
Thanks a lot for catching this!

On Wed, Feb 20, 2013 at 11:22 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
>
> On Wed, Feb 20, 2013 at 7:46 AM, Alexander Potapenko <glider at google.com>
> wrote:
>>
>> Author: glider
>> Date: Wed Feb 20 09:46:02 2013
>> New Revision: 175631
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=175631&view=rev
>> Log:
>> [ASan] Delete asan/dynamic dir and temporarily move the interposers
>> declarations to asan_intercepted_functions.h
>> Now that we have only one dependency on asan_intercepted_functions.h, we
>> can unite that code with the interceptors declarations in
>> asan_interceptors.cc and get rid of asan_intercepted_functions.h
>
>
> I'm going to go out on a limb & suggest that this (or some related changes
> from you recently) caused this:
>
> FAIL: AddressSanitizer-Unit ::
> /usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test/AddressSanitizer.AllocDeallocMismatch
> (41 of 14077)
> ******************** TEST 'AddressSanitizer-Unit ::
> /usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test/AddressSanitizer.AllocDeallocMismatch'
> FAILED ********************
> Note: Google Test filter = AddressSanitizer.AllocDeallocMismatch
> [==========] Running 1 test from 1 test case.
> [----------] Global test environment set-up.
> [----------] 1 test from AddressSanitizer
> [ RUN      ] AddressSanitizer.AllocDeallocMismatch
> =================================================================
> ==14202== ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs
> free) on 0xf7302870
>     #0 0x8094714
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x8094714)
>     #1 0x811009d
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x811009d)
>     #2 0x8254aa5
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x8254aa5)
>     #3 0x82574c2
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x82574c2)
>     #4 0x8258ec9
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x8258ec9)
>     #5 0x82699da
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x82699da)
>     #6 0x828bffb
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x828bffb)
>     #7 0x8269012
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x8269012)
>     #8 0x80c071f
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x80c071f)
> 0xf7302870 is located 0 bytes inside of 4-byte region
> [0xf7302870,0xf7302874)
> allocated by thread T0 here:
>     #0 0x8094c94
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x8094c94)
>     #1 0x811008e
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x811008e)
>     #2 0x8254aa5
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x8254aa5)
>     #3 0x82574c2
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x82574c2)
>     #4 0x8258ec9
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x8258ec9)
>     #5 0x82699da
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x82699da)
>     #6 0x828bffb
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x828bffb)
>     #7 0x8269012
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x8269012)
>     #8 0x80c071f
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-i386-Test+0x80c071f)
> ==14202== HINT: if you don't care about these warnings you may set
> ASAN_OPTIONS=alloc_dealloc_mismatch=0
> ==14202== ABORTING
>
> ********************
> Testing:
> FAIL: AddressSanitizer-Unit ::
> /usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test/AddressSanitizer.AllocDeallocMismatch
> (175 of 14077)
> ******************** TEST 'AddressSanitizer-Unit ::
> /usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test/AddressSanitizer.AllocDeallocMismatch'
> FAILED ********************
> Note: Google Test filter = AddressSanitizer.AllocDeallocMismatch
> [==========] Running 1 test from 1 test case.
> [----------] Global test environment set-up.
> [----------] 1 test from AddressSanitizer
> [ RUN      ] AddressSanitizer.AllocDeallocMismatch
> =================================================================
> ==16677== ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs
> free) on 0x60040000b0f0
>     #0 0x451212
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x451212)
>     #1 0x5ebe67
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x5ebe67)
>     #2 0x5be005
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x5be005)
>     #3 0x5c17fd
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x5c17fd)
>     #4 0x5cf9f9
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x5cf9f9)
>     #5 0x5ed2c7
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x5ed2c7)
>     #6 0x5cf1a6
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x5cf1a6)
> 0x60040000b0f0 is located 0 bytes inside of 4-byte region
> [0x60040000b0f0,0x60040000b0f4)
> allocated by thread T0 here:
>     #0 0x451742
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x451742)
>     #1 0x4b9e3a
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x4b9e3a)
>     #2 0x5be005
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x5be005)
>     #3 0x5c17fd
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x5c17fd)
>     #4 0x5cf9f9
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x5cf9f9)
>     #5 0x5ed2c7
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x5ed2c7)
>     #6 0x5cf1a6
> (/usr/local/google/home/blaikie/dev/llvm/build/clang/debug/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x5cf1a6)
> ==16677== HINT: if you don't care about these warnings you may set
> ASAN_OPTIONS=alloc_dealloc_mismatch=0
> ==16677== ABORTING
>
> ********************
>
> Any ideas?
>
>>
>>
>> Removed:
>>     compiler-rt/trunk/lib/asan/dynamic/
>> Modified:
>>     compiler-rt/trunk/lib/asan/CMakeLists.txt
>>     compiler-rt/trunk/lib/asan/Makefile.mk
>>     compiler-rt/trunk/lib/asan/asan_intercepted_functions.h
>>     compiler-rt/trunk/lib/asan/tests/asan_test.cc
>>
>> Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=175631&r1=175630&r2=175631&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
>> +++ compiler-rt/trunk/lib/asan/CMakeLists.txt Wed Feb 20 09:46:02 2013
>> @@ -25,7 +25,6 @@ set(ASAN_SOURCES
>>
>>  set(ASAN_DYLIB_SOURCES
>>    ${ASAN_SOURCES}
>> -  dynamic/asan_interceptors_dynamic.cc
>>    )
>>
>>  include_directories(..)
>>
>> Modified: compiler-rt/trunk/lib/asan/Makefile.mk
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/Makefile.mk?rev=175631&r1=175630&r2=175631&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/Makefile.mk (original)
>> +++ compiler-rt/trunk/lib/asan/Makefile.mk Wed Feb 20 09:46:02 2013
>> @@ -8,7 +8,7 @@
>>
>> #===------------------------------------------------------------------------===#
>>
>>  ModuleName := asan
>> -SubDirs := dynamic
>> +SubDirs :=
>>
>>  Sources := $(foreach file,$(wildcard $(Dir)/*.cc),$(notdir $(file)))
>>  ObjNames := $(Sources:%.cc=%.o)
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_intercepted_functions.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_intercepted_functions.h?rev=175631&r1=175630&r2=175631&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_intercepted_functions.h (original)
>> +++ compiler-rt/trunk/lib/asan/asan_intercepted_functions.h Wed Feb 20
>> 09:46:02 2013
>> @@ -79,9 +79,36 @@ using __sanitizer::uptr;
>>  # define ASAN_INTERCEPT___CXA_THROW 0
>>  #endif
>>
>> +#define INTERPOSE_FUNCTION(function) \
>> +    { reinterpret_cast<const uptr>(WRAP(function)), \
>> +      reinterpret_cast<const uptr>(function) }
>> +
>> +#define INTERPOSE_FUNCTION_2(function, wrapper) \
>> +    { reinterpret_cast<const uptr>(wrapper), \
>> +      reinterpret_cast<const uptr>(function) }
>> +
>> +struct interpose_substitution {
>> +  const uptr replacement;
>> +  const uptr original;
>> +};
>> +
>> +#define INTERPOSER(func) __attribute__((used)) \
>> +const interpose_substitution substitution_##func[] \
>> +    __attribute__((section("__DATA, __interpose"))) = { \
>> +  INTERPOSE_FUNCTION(func), \
>> +}
>> +
>> +#define INTERPOSER_2(func, wrapper) __attribute__((used)) \
>> +const interpose_substitution substitution_##func[] \
>> +    __attribute__((section("__DATA, __interpose"))) = { \
>> +  INTERPOSE_FUNCTION_2(func, wrapper), \
>> +}
>> +
>> +
>>  #define DECLARE_FUNCTION_AND_WRAPPER(ret_type, func, ...) \
>>    ret_type func(__VA_ARGS__); \
>> -  ret_type WRAP(func)(__VA_ARGS__)
>> +  ret_type WRAP(func)(__VA_ARGS__); \
>> +  INTERPOSER(func)
>>
>>  // Use extern declarations of intercepted functions on Mac and Windows
>>  // to avoid including system headers.
>> @@ -141,7 +168,8 @@ DECLARE_FUNCTION_AND_WRAPPER(char*, strd
>>  DECLARE_FUNCTION_AND_WRAPPER(uptr, strnlen, const char *s, uptr maxlen);
>>  # endif
>>  # if ASAN_INTERCEPT_INDEX
>> -DECLARE_FUNCTION_AND_WRAPPER(char*, index, const char *string, int c);
>> +char* index(const char *string, int c);
>> +INTERPOSER_2(index, WRAP(strchr));
>>  # endif
>>
>>  // stdlib.h
>> @@ -221,17 +249,6 @@ DECLARE_FUNCTION_AND_WRAPPER(int, fscanf
>>                               void* stream, const char *format, ...);
>>  DECLARE_FUNCTION_AND_WRAPPER(int, sscanf,  // NOLINT
>>                               const char *str, const char *format, ...);
>> -DECLARE_FUNCTION_AND_WRAPPER(int, __isoc99_vscanf, const char *format,
>> -                             va_list ap);
>> -DECLARE_FUNCTION_AND_WRAPPER(int, __isoc99_vsscanf, const char *str,
>> -                             const char *format, va_list ap);
>> -DECLARE_FUNCTION_AND_WRAPPER(int, __isoc99_vfscanf, void *stream,
>> -                             const char *format, va_list ap);
>> -DECLARE_FUNCTION_AND_WRAPPER(int, __isoc99_scanf, const char *format,
>> ...);
>> -DECLARE_FUNCTION_AND_WRAPPER(int, __isoc99_fscanf,
>> -                             void* stream, const char *format, ...);
>> -DECLARE_FUNCTION_AND_WRAPPER(int, __isoc99_sscanf,  // NOLINT
>> -                             const char *str, const char *format, ...);
>>  # endif
>>
>>  # if defined(__APPLE__)
>> @@ -294,9 +311,11 @@ DECLARE_FUNCTION_AND_WRAPPER(void *, val
>>  DECLARE_FUNCTION_AND_WRAPPER(size_t, malloc_good_size, size_t size);
>>  DECLARE_FUNCTION_AND_WRAPPER(int, posix_memalign,
>>                               void **memptr, size_t alignment, size_t
>> size);
>> +#if 0
>>  DECLARE_FUNCTION_AND_WRAPPER(void, _malloc_fork_prepare, void);
>>  DECLARE_FUNCTION_AND_WRAPPER(void, _malloc_fork_parent, void);
>>  DECLARE_FUNCTION_AND_WRAPPER(void, _malloc_fork_child, void);
>> +#endif
>>
>>
>>
>>
>> Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=175631&r1=175630&r2=175631&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
>> +++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Wed Feb 20 09:46:02 2013
>> @@ -1133,11 +1133,15 @@ TEST(AddressSanitizer, AttributeNoAddres
>>
>>  // It doesn't work on Android, as calls to new/delete go through
>> malloc/free.
>>  #if !defined(ANDROID) && !defined(__ANDROID__)
>> +#if 0
>>  static string MismatchStr(const string &str) {
>>    return string("AddressSanitizer: alloc-dealloc-mismatch \\(") + str;
>>  }
>> +#endif
>>
>>  TEST(AddressSanitizer, AllocDeallocMismatch) {
>> +  free(Ident(new int));
>> +#if 0
>>    EXPECT_DEATH(free(Ident(new int)),
>>                 MismatchStr("operator new vs free"));
>>    EXPECT_DEATH(free(Ident(new int[2])),
>> @@ -1150,6 +1154,7 @@ TEST(AddressSanitizer, AllocDeallocMisma
>>                 MismatchStr("operator new vs operator delete \\[\\]"));
>>    EXPECT_DEATH(delete [] (Ident((int*)malloc(2 * sizeof(int)))),
>>                 MismatchStr("malloc vs operator delete \\[\\]"));
>> +#endif
>>  }
>>  #endif
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>



--
Alexander Potapenko
Software Engineer
Google Moscow



More information about the llvm-commits mailing list