<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58404>58404</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [ASan] Feature request: Allow ignoring some new-delete-type-mismatch without disabling it altogether
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          j1elo
      </td>
    </tr>
</table>

<pre>
    I want to analyze my application code for **new-delete-type-mismatch** issues, with AddressSanitizer. However, in order to do this, first I'd like to disable such reports from 3rd-party code and focus on my own.

libsigc++ is one such example, a dependency where a *new-delete-type-mismatch* **false positive** occurs, it's a well known issue, and cannot be easily solved:

> To the specially instrumented code, generated by the -fsanitize=address compiler option,
> it looks like a typed_slot_rep instance has been allocated, but only a slot_rep instance
> has been deallocated. This is, I'm pretty sure, of no concern to normal C++ code.
> [...]
> I can understand that the error messages from -fsanitize=address cause concern,
> but I believe that they can be ignored in this case. It's not nice, but we will
> probably have to accept it in sigc++-2.0.

([Full conversation here](https://github.com/libsigcplusplus/libsigcplusplus/issues/10#issuecomment-427092213), for context)

The way to suppress such errors from ASan is to use `__attribute__((no_sanitize("address")))`, however this does not disable *new-delete-type-mismatch* errors. After too much time fiddling with this, turns out that due to [a technicality of how this detection works](https://github.com/google/sanitizers/issues/1000#issuecomment-424943176) (something which by the way is not documented, and I believe should be because this distinction is not apparent or obvious at all to end users), the false positive in libsigc++ (or any other third party code, to that matter) cannot be disabled while still leaving the detection enabled for 1st-party code.

A minimal reproduction sample was [written by @kjellahl](https://github.com/libsigcplusplus/libsigcplusplus/issues/10#issuecomment-1279981654) and I'm attaching it here too:

[asan_test.cc](https://github.com/llvm/llvm-project/files/9799904/asan_test.cc.txt)

Build it with this command line:

```
clang++ -o asan_test asan_test.cc -fsanitize=address -fsized-deallocation -std=c++14 -g
```

The feature of ignore lists does not work either, probably due to the same reasons. So, having `fun:*bad_function*` in the ignore list, and building like follows, will not disable *new-delete-type-mismatch* errors:

```
clang++ -o asan_test asan_test.cc -fsanitize=address -fsized-deallocation -fsanitize-blacklist=blacklist.txt -std=c++14 -g
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9Vsty2zgQ_BrqghKLomQ9Djoo8brW5-SuAomhhBgEuABoRfn67QGphxNnsznsVtEPUiDQ093To8qp8_ZZnKSNIjohrTTnbyTas5BdZ3Qto3ZW1E6RaJwXWbnDZek0VWQo0jSeO5q2OrQy1sfhU6FD6Clk5Udx0vEodkp5CuGTtDrqb-Rz8ac70St5XqGtcF6R58OVE_Go04uN9iGK56xcKWH0C6WPdZCVIRH6-ig8dc7HIBrvWjH3atpJH88DUGkVwNZ9EICOStzJ5lnxmBW74bfRVdCHOis_4AJaLBt3pa-y7QwxAikUdWQV2fosTkfy2Ff8c-0jO400gUTnAsp9pZETV9e9T6XpiKoCNjuRMeLFAt3AWDoV0GtprYuiIkEyaHMWwZlXUtl8d19ENv9DfGbCAL2jWkuDldqG6PuWbCSVuOA9D2TJS35SndP6aRNGLbL5oxzUweq20wZCuI4lx4u3c3QUxrmXMEghBReu9sG4uIcO6VRpaxJHGQCbrAAYV_ORfH7VRzAMdFL88MrtjOu7iq5v5-Iz_CAGS7AZWtF5itA59D7V5hphHbBjK2_ZJNb5VhrxcRSXOchvh2QPH_I8zx4eb4-emW_RQ2jPkBQYkjHRRN7D8S3IkQcanfY-dbKH4COIN8Rx6c8oy2j4_brzOR0JffUBcKELmoCNj8eBcvE8GIQ9YHVNFwpPhHYy5rZ5512FhjiDutfUILKuqYusFja8OXxa5sUb_2flGkQ89bAfQKMRw9DlbHLmplwfY-wCG658wnVAF_dVDofgZmyezvSBf959cgmAp1mRlfN0h5fZltNFuSo2ZTmbZ-UmNTooBohIXyM_uUP5GRKc5JkLC33XJaaHJmVdRj12SBXuYCxiDbJlsd_LGL0GY7Tfc6Xl2rr9VTV-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