Bug 148623 - Implement bmalloc::isASanEnabled for generic Unix
Summary: Implement bmalloc::isASanEnabled for generic Unix
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: Other
Hardware: All All
: P2 Enhancement
Assignee: Michael Catanzaro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-30 16:30 PDT by Michael Catanzaro
Modified: 2015-08-31 13:41 PDT (History)
3 users (show)

See Also:


Attachments
Patch (2.35 KB, patch)
2015-08-30 16:34 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff
Patch (2.39 KB, patch)
2015-08-30 16:43 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff
Patch (1.92 KB, patch)
2015-08-31 09:31 PDT, Michael Catanzaro
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2015-08-30 16:30:09 PDT
If you only care about Clang (not sure), bmalloc::isASanEnabled could be as simple as:

static bool isASanEnabled()
{
#if defined(__has_feature) && __has_feature(address_sanitizer)
    return true;
#else
    return false;
#endif
}

Unless there is some reason I don't understand for the runtime check.

GCC supports asan but not __has_feature. This runtime check works:

    void *handle = dlopen(nullptr, RTLD_NOW);
    if (!handle)
        return false;
    bool result = !!dlsym(handle, "__asan_poison_memory_region");
    dlclose(handle);
    return result;

I expect that would work fine on Darwin too.
Comment 1 Michael Catanzaro 2015-08-30 16:34:34 PDT
Created attachment 260254 [details]
Patch
Comment 2 Michael Catanzaro 2015-08-30 16:43:54 PDT
Created attachment 260255 [details]
Patch
Comment 3 Alexey Proskuryakov 2015-08-30 17:43:05 PDT
The runtime check is needed because we need to disable bmalloc whenever ASan is enabled in the process - even if bmalloc itself is compiled without ASan.
Comment 4 Michael Catanzaro 2015-08-31 09:28:56 PDT
OK, that makes sense.
Comment 5 Michael Catanzaro 2015-08-31 09:31:30 PDT
Created attachment 260289 [details]
Patch
Comment 6 Geoffrey Garen 2015-08-31 13:16:47 PDT
Comment on attachment 260289 [details]
Patch

r=me
Comment 7 Michael Catanzaro 2015-08-31 13:41:41 PDT
Committed r189181: <http://trac.webkit.org/changeset/189181>