[clang] [compiler-rt] [ASan] Document define to disable container overflow checks at compile time. (PR #163468)

Louis Dionne via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 3 10:46:20 PST 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:

Changing libc++ is not a problem. I think we're happy to include the header, too, as long as compiler-rt headers are guaranteed to be dependency-free.

Personally, I'd just declare `__sanitizer_annotate_contiguous_container` like this:

```c++
#ifdef __ASAN_DISABLE_CONTAINER_OVERFLOW__
__attribute__((__internal_linkage__)) inline
void __sanitizer_annotate_contiguous_container(const void *, const void *, const void *, const void*) { }
#else
void __sanitizer_annotate_contiguous_container(const void *, const void *, const void *, const void*);
#endif
```

Naming-wise, I am not a big fan of `__sanitizer_maybe_annotate_contiguous_container`, I'd rather just use `__sanitizer_annotate_contiguous_container`. But whatever, we'll use what you folks provide.

N.B.: You have to make sure to mangle all identifiers in compiler-rt headers, for example parameter names must start with `__`.

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


More information about the llvm-commits mailing list