[libcxx-commits] [PATCH] D136765: [ASan][libcxx] Annotating std::vector with all allocators

Tacet via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Feb 19 21:05:30 PST 2023


AdvenamTacet updated this revision to Diff 498716.
AdvenamTacet added a comment.

This update should fix problems with zero allocators and add tests confirming it.
It adds fixes to std::vector annotations unpoisoning, originally suggested in D144155 <https://reviews.llvm.org/D144155>.  It guarantees that __alloc_traits::deallocate may access returned memory. (Details below.)
It adds a new test allocator (`safe_allocator`), this allocator accesses memory during allocation and deallocation.
It extends existing and relevant tests to use that allocator as well. This should show that a similar problem to the one which happened won’t happen again.

Short description of the fix:
A call to `__annotate_delete()` in  `operator()` (in `__destroy_vector` class) is moved after a call to `clear()`, because clear may poison memory (as container overflow - fc).
It also adds unpoisoning memory before passing it to the deallocator in `__vdeallocate()` and `__copy_assign_alloc(const vector& __c, true_type)`.
Current implementation is not correct and works only because annotations are turned on for only the standard allocator, as well as its implementation does not access memory at all, it may change with implementation change. You can see details in D144155 <https://reviews.llvm.org/D144155>.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136765/new/

https://reviews.llvm.org/D136765

Files:
  libcxx/include/vector
  libcxx/test/libcxx/containers/sequences/vector/asan.pass.cpp
  libcxx/test/std/containers/sequences/vector/access.pass.cpp
  libcxx/test/std/containers/sequences/vector/contiguous.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.erasure/erase.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_lvalue.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
  libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
  libcxx/test/support/min_allocator.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136765.498716.patch
Type: text/x-patch
Size: 45067 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230220/7441c048/attachment-0001.bin>


More information about the libcxx-commits mailing list