[libcxx-commits] [libcxx] [libc++] Use correct size for deallocation of arrays in shared_ptr (PR #68233)

Ilya Biryukov via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 5 06:23:31 PDT 2023


ilya-biryukov wrote:

> I wonder why ASAN wasn't flagging this externally. Any clues?


> Thanks for the fix! This is indeed a nasty bug, a bit surprising that it went unnoticed for so long.

I think it's because it requires a rather rare combination of flags. First, we need to enable `-fsized-deallocation`[1] and build with ASan. In addition, one either needs to use `std::boyer_moore_searcher` in C++17 (which is a likely a rarely used API) or  C++20's `std::make_shared` with array types (which should be more common, but C++20 is relatively rare itself).

[1]: it is surprising that `-fsized-deallocation` is not the default yet given that it was part of C++14. There was an [attempt](https://reviews.llvm.org/D112921#4624744) to make it the default in August 2023, but it got reverted.

https://github.com/llvm/llvm-project/pull/68233


More information about the libcxx-commits mailing list