[llvm] [LLVM][Coverage][Unittest] Fix dangling reference in unittest (PR #147118)

Tomohiro Kashiwada via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 11 04:31:47 PDT 2025


kikairoya wrote:

> If I understand it correctly, this issue should be observable anywhere by building and running this unit test with address sanitizer, no?

Ideally, yes.
However, in my understanding by reading implementation of `libstdc++` and `libc++`, `std::vector::clear` doesn't deallocate memory, but only tells the address sanitizer that the valid area has been shrunk.
Therefore, `asan` can't catch use-after-free if `resize` (it tells `asan` valid area will be expanded) immediately follows `clear` because there is no one accessing the freed memory.

If there were a sanitizer capable of detecting access to destroyed objects via a pseudo-destructor call, this issue should be detected.

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


More information about the llvm-commits mailing list