291291// - `_LIBCPP_ASSERT_NON_OVERLAPPING_RANGES` -- for functions that take several ranges as arguments, checks that the
292292// given ranges do not overlap.
293293//
294+ // - `_LIBCPP_ASSERT_VALID_DEALLOCATION` -- checks that an attempt to deallocate memory is valid (e.g. the given object
295+ // was allocated by the given allocator). Violating this category typically results in a memory leak.
296+ //
297+ // - `_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL` -- checks that a call to an external API doesn't fail in
298+ // an unexpected manner. This includes triggering documented cases of undefined behavior in an external library (like
299+ // attempting to unlock an unlocked mutex in pthreads). Any API external to the library falls under this category
300+ // (from system calls to compiler intrinsics). We generally don't expect these failures to compromize memory safety or
301+ // otherwise create an immediate security issue.
302+ //
294303// - `_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR` -- checks any operations that exchange nodes between containers to make sure
295304// the containers have compatible allocators.
296305//
@@ -345,8 +354,10 @@ _LIBCPP_HARDENING_MODE_DEBUG
345354// Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security
346355// vulnerability.
347356# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES (expression, message ) _LIBCPP_ASSUME(expression)
348- # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN (expression, message ) _LIBCPP_ASSUME(expression)
357+ # define _LIBCPP_ASSERT_VALID_DEALLOCATION (expression, message ) _LIBCPP_ASSUME(expression)
358+ # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL (expression, message ) _LIBCPP_ASSUME(expression)
349359# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR (expression, message ) _LIBCPP_ASSUME(expression)
360+ # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN (expression, message ) _LIBCPP_ASSUME(expression)
350361# define _LIBCPP_ASSERT_PEDANTIC (expression, message ) _LIBCPP_ASSUME(expression)
351362# define _LIBCPP_ASSERT_INTERNAL (expression, message ) _LIBCPP_ASSUME(expression)
352363# define _LIBCPP_ASSERT_UNCATEGORIZED (expression, message ) _LIBCPP_ASSUME(expression)
@@ -360,6 +371,8 @@ _LIBCPP_HARDENING_MODE_DEBUG
360371# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (expression, message ) _LIBCPP_ASSERT(expression, message)
361372# define _LIBCPP_ASSERT_NON_NULL (expression, message ) _LIBCPP_ASSERT(expression, message)
362373# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES (expression, message ) _LIBCPP_ASSERT(expression, message)
374+ # define _LIBCPP_ASSERT_VALID_DEALLOCATION (expression, message ) _LIBCPP_ASSERT(expression, message)
375+ # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL (expression, message ) _LIBCPP_ASSERT(expression, message)
363376# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR (expression, message ) _LIBCPP_ASSERT(expression, message)
364377# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN (expression, message ) _LIBCPP_ASSERT(expression, message)
365378# define _LIBCPP_ASSERT_PEDANTIC (expression, message ) _LIBCPP_ASSERT(expression, message)
@@ -376,6 +389,8 @@ _LIBCPP_HARDENING_MODE_DEBUG
376389# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (expression, message ) _LIBCPP_ASSERT(expression, message)
377390# define _LIBCPP_ASSERT_NON_NULL (expression, message ) _LIBCPP_ASSERT(expression, message)
378391# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES (expression, message ) _LIBCPP_ASSERT(expression, message)
392+ # define _LIBCPP_ASSERT_VALID_DEALLOCATION (expression, message ) _LIBCPP_ASSERT(expression, message)
393+ # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL (expression, message ) _LIBCPP_ASSERT(expression, message)
379394# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR (expression, message ) _LIBCPP_ASSERT(expression, message)
380395# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN (expression, message ) _LIBCPP_ASSERT(expression, message)
381396# define _LIBCPP_ASSERT_PEDANTIC (expression, message ) _LIBCPP_ASSERT(expression, message)
@@ -391,6 +406,8 @@ _LIBCPP_HARDENING_MODE_DEBUG
391406# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (expression, message ) _LIBCPP_ASSUME(expression)
392407# define _LIBCPP_ASSERT_NON_NULL (expression, message ) _LIBCPP_ASSUME(expression)
393408# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES (expression, message ) _LIBCPP_ASSUME(expression)
409+ # define _LIBCPP_ASSERT_VALID_DEALLOCATION (expression, message ) _LIBCPP_ASSUME(expression)
410+ # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL (expression, message ) _LIBCPP_ASSUME(expression)
394411# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR (expression, message ) _LIBCPP_ASSUME(expression)
395412# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN (expression, message ) _LIBCPP_ASSUME(expression)
396413# define _LIBCPP_ASSERT_PEDANTIC (expression, message ) _LIBCPP_ASSUME(expression)
0 commit comments