[libcxx-commits] [libcxx] [libc++][hardening] Classify assertions related to leaks and syscalls. (PR #77164)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 7 05:18:10 PST 2024


================
@@ -280,6 +280,14 @@
 // - `_LIBCPP_ASSERT_NON_OVERLAPPING_RANGES` -- for functions that take several ranges as arguments, checks that the
 //   given ranges do not overlap.
 //
+// - `_LIBCPP_ASSERT_VALID_DEALLOCATION` -- checks that an attempt to deallocate memory is valid (e.g. the given object
+//   was allocated by the given allocator). Violating this category typically results in a memory leak.
+//
+// - `_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL` -- checks that a call to an external API (e.g. a syscall) doesn't fail in
+//   an unexpected manner. This includes triggering documented cases of undefined behavior in an external library (like
+//   attempting to unlock an unlocked mutex in pthreads). We generally don't expect these failures to compromize memory
+//   safety or otherwise create an immediate security issue.
+//
----------------
mordante wrote:

Not specific to this commit, but I feel this list is getting a bit long in here. How about putting it in an `.rst` file. I also would like a better overview what the modi do. For example, what does `_LIBCPP_HARDENING_MODE_FAST`  do.
Maybe a summary lke
```
* _LIBCPP_HARDENING_MODE_FAST
  * foo
  * bar
* _LIBCPP_HARDENING_MODE_EXTENSIVE
   * all of _LIBCPP_HARDENING_MODE_FAST
   * do
   * re
   * mi
```


https://github.com/llvm/llvm-project/pull/77164


More information about the libcxx-commits mailing list