Changeset 200654 in webkit


Ignore:
Timestamp:
May 10, 2016, 4:47:10 PM (9 years ago)
Author:
ddkilzer@apple.com
Message:

bmalloc should automatically disable itself when ThreadSanitizer is used
<https://webkit.org/b/157527>

Reviewed by Michael Catanzaro.

  • bmalloc/Environment.cpp:

(bmalloc::isASanEnabled): Rename to isSanitizerEnabled.
(bmalloc::isSanitizerEnabled): Rename from isASanEnabled. Add
support for detecting ThreadSanitizer.
(bmalloc::Environment::computeIsBmallocEnabled): Switch from
isASanEnabled to isSanitizerEnabled.

Location:
trunk/Source/bmalloc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/bmalloc/ChangeLog

    r200386 r200654  
     12016-05-10  David Kilzer  <ddkilzer@apple.com>
     2
     3        bmalloc should automatically disable itself when ThreadSanitizer is used
     4        <https://webkit.org/b/157527>
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        * bmalloc/Environment.cpp:
     9        (bmalloc::isASanEnabled): Rename to isSanitizerEnabled.
     10        (bmalloc::isSanitizerEnabled): Rename from isASanEnabled. Add
     11        support for detecting ThreadSanitizer.
     12        (bmalloc::Environment::computeIsBmallocEnabled): Switch from
     13        isASanEnabled to isSanitizerEnabled.
     14
    1152016-05-03  Geoffrey Garen  <ggaren@apple.com>
    216
  • trunk/Source/bmalloc/bmalloc/Environment.cpp

    r189181 r200654  
    7676}
    7777
    78 static bool isASanEnabled()
     78static bool isSanitizerEnabled()
    7979{
    8080#if BOS(DARWIN)
     81    static const char sanitizerPrefix[] = "/libclang_rt.";
     82    static const char asanName[] = "asan_";
     83    static const char tsanName[] = "tsan_";
    8184    uint32_t imageCount = _dyld_image_count();
    8285    for (uint32_t i = 0; i < imageCount; ++i) {
     
    8487        if (!imageName)
    8588            continue;
    86         if (strstr(imageName, "/libclang_rt.asan_"))
    87             return true;
     89        if (const char* s = strstr(imageName, sanitizerPrefix)) {
     90            const char* sanitizerName = s + sizeof(sanitizerPrefix) - 1;
     91            if (!strncmp(sanitizerName, asanName, sizeof(asanName) - 1))
     92                return true;
     93            if (!strncmp(sanitizerName, tsanName, sizeof(tsanName) - 1))
     94                return true;
     95        }
    8896    }
    8997    return false;
     
    92100    if (!handle)
    93101        return false;
    94     bool result = !!dlsym(handle, "__asan_poison_memory_region");
     102    bool result = !!dlsym(handle, "__asan_init") || !!dlsym(handle, "__tsan_init");
    95103    dlclose(handle);
    96104    return result;
     
    111119    if (isLibgmallocEnabled())
    112120        return false;
    113     if (isASanEnabled())
     121    if (isSanitizerEnabled())
    114122        return false;
    115123    return true;
Note: See TracChangeset for help on using the changeset viewer.