[clang] [compiler-rt] [ASan] Document define to disable container overflow checks at compile time. (PR #163468)
Louis Dionne via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 30 11:07:25 PDT 2025
================
@@ -242,6 +255,43 @@ AddressSanitizer also supports
works similar to ``__attribute__((no_sanitize("address")))``, but it also
prevents instrumentation performed by other sanitizers.
+Disabling container overflow checks
+-----------------------------------
+
+Runtime suppression
+^^^^^^^^^^^^^^^^^^^
+
+Container overflow checks can be disabled at runtime using
+``ASAN_OPTIONS=detect_container_overflow=0``
+
+Compile time suppression
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+``-D__ASAN_DISABLE_CONTAINER_OVERFLOW__`` can be used at compile time to
+disable container overflow checks if the container library has added support
+for this define.
----------------
ldionne wrote:
My vote goes for either (1) or (2). I find it surprising that `__sanitizer_annotate_contiguous_container` is either a macro or a function depending on this flag, which changes whether its arguments are evaluated, ODR-used, etc.
Also, if it's a macro, the following will bypass the mechanism you're trying to put in place:
```
auto f = & __sanitizer_annotate_contiguous_container.
f(beg, end, old_mid, new_mid); // not a noop even if __ASAN_DISABLE_CONTAINER_OVERFLOW__ is defined.
```
I think this merely highlights the weird behavior you can get when introducing a macro into the mix.
https://github.com/llvm/llvm-project/pull/163468
More information about the cfe-commits
mailing list