[llvm] [ASan][JSON] Unpoison memory before its reuse (PR #79065)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 23:06:11 PST 2024


AdvenamTacet wrote:

> could you explain why this is necessary? I'm not understanding at a first glance

Sure! In https://github.com/llvm/llvm-project/pull/75845 I added annotations for `std::basic_string`, but only when string has an external buffer. Now in https://github.com/llvm/llvm-project/pull/79049#pullrequestreview-1837807790 I'm trying to turn on annotations for short string (so when content is kept inside string object).

In case of a short string, objects memory is poisoned. And if a destructor is not called before `create`, a new object may be created in poisoned memory. (And if string is long, it may lead to a memory leak.)

It would be best to call a destructor, but I didn't figure out how yet and we want to land short string annotations before branching, so it's a workaround to not make buildbots fail.

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


More information about the llvm-commits mailing list