summaryrefslogtreecommitdiffstats
path: root/libcxx/include/__debug
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2019-03-05 02:10:31 +0000
committerEric Fiselier <eric@efcs.ca>2019-03-05 02:10:31 +0000
commit1c014d75b4cdcfab5cef304e5f9c5def96468751 (patch)
tree5be06a180e101fba1baa66173ee9bd60b254db47 /libcxx/include/__debug
parente69290dc7ff7319acf5904f15ab6630fad07ab58 (diff)
downloadbcm5719-llvm-1c014d75b4cdcfab5cef304e5f9c5def96468751.tar.gz
bcm5719-llvm-1c014d75b4cdcfab5cef304e5f9c5def96468751.zip
Fix -fsanitize=vptr badness in <__debug>
Summary: This patch fixes a lifetime bug when inserting a new container into the debug database. It is diagnosed by UBSAN when debug mode is enabled. This patch corrects how nodes are constructed during insertion. The fix requires unconditionally breaking the debug mode ABI. Users should not expect ABI stability from debug mode. Reviewers: ldionne, serge-sans-paille, EricWF Reviewed By: EricWF Subscribers: mclow.lists, christof, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D58011 llvm-svn: 355367
Diffstat (limited to 'libcxx/include/__debug')
-rw-r--r--libcxx/include/__debug12
1 files changed, 9 insertions, 3 deletions
diff --git a/libcxx/include/__debug b/libcxx/include/__debug
index 6ccb72cb8ad..281cf6675c9 100644
--- a/libcxx/include/__debug
+++ b/libcxx/include/__debug
@@ -250,16 +250,22 @@ public:
__db_c_const_iterator __c_end() const;
__db_i_const_iterator __i_end() const;
+ typedef __c_node*(_InsertConstruct)(void*, void*, __c_node*);
+
+ template <class _Cont>
+ _LIBCPP_INLINE_VISIBILITY static __c_node* __create_C_node(void *__mem, void *__c, __c_node *__next) {
+ return ::new(__mem) _C_node<_Cont>(__c, __next);
+ }
+
template <class _Cont>
_LIBCPP_INLINE_VISIBILITY
void __insert_c(_Cont* __c)
{
- __c_node* __n = __insert_c(static_cast<void*>(__c));
- ::new(__n) _C_node<_Cont>(__n->__c_, __n->__next_);
+ __insert_c(static_cast<void*>(__c), &__create_C_node<_Cont>);
}
void __insert_i(void* __i);
- __c_node* __insert_c(void* __c);
+ void __insert_c(void* __c, _InsertConstruct* __fn);
void __erase_c(void* __c);
void __insert_ic(void* __i, const void* __c);
OpenPOWER on IntegriCloud