<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Implement bmalloc::isASanEnabled for Clang and generic Unix"
   href="https://bugs.webkit.org/show_bug.cgi?id=148623">148623</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Implement bmalloc::isASanEnabled for Clang and generic Unix
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Web Template Framework
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mcatanzaro&#64;igalia.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>If you only care about Clang (not sure), bmalloc::isASanEnabled could be as simple as:

static bool isASanEnabled()
{
#if defined(__has_feature) &amp;&amp; __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, &quot;__asan_poison_memory_region&quot;);
    dlclose(handle);
    return result;

I expect that would work fine on Darwin too.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>