[libcxx-commits] [PATCH] D144155: [ASan] Unpoisoning vectors memory before deallocation
Tacet via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 16 00:29:45 PST 2023
AdvenamTacet added a comment.
The point of `__annotate_delete` is to return memory in the same state as it was just after allocation. And yes, `clear()` is poisoning memory of all present objects in a vector (at the end, whole buffer is poisoned as container overflow).
1. Therefore, there is no point to unpoison memory before a call to `clear`.
2. I don't think clear() is called there because of ASan, as from ASan point of view, container does not have to be empty.
3. The goal is to deallocate unpoisoned memory and there is no easy way to turn off poisoning inside a single call to the `clear` function (at least I don't know it).
If complexity is the main concern, I can add additional `if` before every `__annotate_delete()` call, and don't call them with standard allocator, as in that implementation, it's not necessary. But it depends on memory deallocator implementation.
Also, that memory will be probably poisoned by deallocator soon after, but sometimes deallocator may access memory and then it cannot be poisoned <https://github.com/llvm/llvm-project/issues/60384>.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144155/new/
https://reviews.llvm.org/D144155
More information about the libcxx-commits
mailing list