hanchenye-llvm-project/libcxx/include
Thomas Anderson 516d07de07 [libc++] Fix use-after-free when building with _LIBCPP_DEBUG=1
The issue is the following code:

    __cn1->__add(*__ip);
    (*__ip)->__c_ = __cn1;

`__ip` points into the array of iterators for container `__cn2`.  This code adds
the iterator to the array of iterators for `__cn1`, and updates the iterator to
point to the new container.

This code works fine, except when `__cn1` and `__cn2` are the same container.
`__cn1->__add()` might need to grow the array of iterators, and when it does,
`__ip` becomes invalid, so the second line becomes a use-after-free error.

Simply swapping the order of the above two lines is not sufficient, because of
the memmove() below.  The easiest and most performant solution is just to skip
touching any iterators if the containers are the same.

Differential Revision: https://reviews.llvm.org/D58926

llvm-svn: 355550
2019-03-06 21:10:08 +00:00
..
experimental [libc++] Remove visibility-related warnings with Clang 8 2019-02-27 17:33:25 +00:00
ext Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
support Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
CMakeLists.txt Add fenv.h header 2019-02-11 23:47:19 +00:00
__bit_reference Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__bsd_locale_defaults.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__bsd_locale_fallbacks.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__config Reinstate libc++ patches now that the lldb formatter has been updated. 2019-03-05 18:40:49 +00:00
__config_site.in Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__debug Fix -fsanitize=vptr badness in <__debug> 2019-03-05 02:10:31 +00:00
__errc Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__functional_03 Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__functional_base Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__functional_base_03 Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__hash_table Add UBSAN annotation to __hash_table::rehash; we don't do anything wrong, but UBSAN's checker flags it as suspicious. See PR38606. NFC 2019-02-07 18:53:58 +00:00
__libcpp_version Bump the trunk version to 9.0.0svn 2019-01-16 10:57:02 +00:00
__locale Fix the build with gcc when `-Wredundant-decls` is passed 2019-02-20 21:01:31 +00:00
__mutex_base Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__node_handle [libc++] Remove visibility-related warnings with Clang 8 2019-02-27 17:33:25 +00:00
__nullptr Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__split_buffer [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on Windows 2017-05-31 22:07:49 +00:00
__sso_allocator Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__std_stream Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__string Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
__threading_support Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__tree Apply D28248: 'Work around GCC PR37804'. Thanks to mdaniels for the patch 2019-01-23 23:06:18 +00:00
__tuple Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__undef_macros Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
algorithm Add a specialization for '__unwrap_iter' to handle const interators. This enables the 'memmove' optimization for std::copy, etc. 2019-02-06 16:10:25 +00:00
any Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
array Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
atomic [libc++] Do not specify the underlying type of memory_order 2019-03-06 17:07:24 +00:00
bit Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
bitset Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cassert Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
ccomplex Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cctype Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cerrno Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cfenv Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cfloat Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
charconv Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
chrono fix -Wextra-semi warnings 2019-02-10 18:29:00 +00:00
cinttypes Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ciso646 Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
climits Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
clocale Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cmath Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
codecvt Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
compare Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
complex Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
complex.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
condition_variable Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
csetjmp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
csignal Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstdarg Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstdbool Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstddef Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstdint Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstdio Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstdlib Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstring Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ctgmath Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
ctime Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
ctype.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cwchar Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cwctype Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
deque Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
errno.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
exception Make VCRuntime ABI configuration a first-class option. 2019-03-05 01:57:01 +00:00
fenv.h Don't declare fenv.h functions when they're a macro. 2019-02-12 00:05:14 +00:00
filesystem [NFC][libc++] Reindent function 2019-02-05 15:46:52 +00:00
float.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
forward_list Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
fstream Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
functional [libc++] Fix Windows build error in <functional> 2019-01-29 23:19:45 +00:00
future Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
initializer_list Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
inttypes.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
iomanip Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
ios [libc++] Avoid UB in the no-exceptions mode in a few places 2019-02-12 16:06:02 +00:00
iosfwd Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
iostream Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
istream Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
iterator In the review of D58642, Louis asked: 'Is there a reason for making this inline? Templates are already inline by default'. I told him that I didn't want to change the one call (ssize) that I was adding, but would come back later and clean them all (data/empty/begin/end/cbegin/cend/rbegin/rend/crbegin/crend/size/ssize) up later. Now it is later. Remove the unnecessary 'inline' modifiers from all these calls. 2019-02-27 03:25:43 +00:00
limits Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
limits.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
list [libc++] Fix use-after-free when building with _LIBCPP_DEBUG=1 2019-03-06 21:10:08 +00:00
locale add a test and a couple minor bug fixes for the implicit-signed-integer-truncation sanitizer. This is PR#40566 2019-02-01 21:59:27 +00:00
locale.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
map [libc++] Avoid UB in the no-exceptions mode in a few places 2019-02-12 16:06:02 +00:00
math.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
memory Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
module.modulemap Add fenv.h header 2019-02-11 23:47:19 +00:00
mutex Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
new Make VCRuntime ABI configuration a first-class option. 2019-03-05 01:57:01 +00:00
numeric Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
optional Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
ostream Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
queue Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
random Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
ratio Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
regex Change a couple of '&' to addressof(). NFC 2019-01-24 02:02:50 +00:00
scoped_allocator Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
set Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
setjmp.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
shared_mutex Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
span Eradicate all the ptrdiff_ts in span left over from applying P1227. A couple of other minor cleanups. NFC 2019-03-06 03:59:44 +00:00
sstream add a test and a couple minor bug fixes for the implicit-signed-integer-truncation sanitizer. This is PR#40566 2019-02-01 21:59:27 +00:00
stack Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
stdbool.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
stddef.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
stdexcept Fix ABI compatibility of `<stdexcept>` with VCRuntime. 2019-03-06 20:31:57 +00:00
stdint.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
stdio.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
stdlib.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
streambuf Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
string Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
string.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
string_view Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
strstream Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
system_error Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
tgmath.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
thread Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
tuple Add static_asserts to tuple's comparison operators to enforce the requirement that the tuples be the same size. See PR39183 for an example where we give unexpected results for this bad input case. With this change, we will reject it at compile-time 2019-02-07 19:03:48 +00:00
type_traits [libc++] Add is_nothrow_convertible from P0758R1 2019-02-27 17:57:38 +00:00
typeindex Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
typeinfo Make VCRuntime ABI configuration a first-class option. 2019-03-05 01:57:01 +00:00
unordered_map [libc++] Avoid UB in the no-exceptions mode in a few places 2019-02-12 16:06:02 +00:00
unordered_set Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
utility Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
valarray Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
variant Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
vector Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
version Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
wchar.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
wctype.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00