[clang] [compiler-rt] [ASan] Document define to disable container overflow checks at compile time. (PR #163468)
Paddy McDonald via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 23 12:17:15 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.
----------------
padriff wrote:
Just adding the simple no implementation body will lead to linkers complaining about multiple definitions in the build.
I added two new test files in the PR to demonstrates the issue and what I think are the approaches that could work in the sanitizer headers:
stack_container_dynamic_lib.cpp uses the approach that library providers do the work to remove the container overflow instrumentation
stack_container_dynamic_lib_redef.cpp shows three alternate approaches to providing the solution in the santizer headers when
__ASAN_DISABLE_CONTAINER_OVERFLOW__ is defined:
- provide an alternate empty body that is force inlined
- provide an alternate empty body that is declared with static linkage
- use a #define to remove the calls from the library sources
The _redef test shows that we can do this with minimal changes to something like libcpp - they would just need to use the sanitizer interface headers rather than declaring the functions themselves
https://github.com/llvm/llvm-project/pull/163468
More information about the llvm-commits
mailing list