1 ===========================
2 Sanitizer special case list
3 ===========================
11 This document describes the way to disable or alter the behavior of
12 sanitizer tools for certain source-level entities by providing a special
18 User of sanitizer tools, such as :doc:`AddressSanitizer`, :doc:`ThreadSanitizer`
19 or :doc:`MemorySanitizer` may want to disable or alter some checks for
20 certain source-level entities to:
22 * speedup hot function, which is known to be correct;
23 * ignore a function that does some low-level magic (e.g. walks through the
24 thread stack, bypassing the frame boundaries);
25 * ignore a known problem.
27 To achieve this, user may create a file listing the entities they want to
28 ignore, and pass it to clang at compile-time using
29 ``-fsanitize-blacklist`` flag. See :doc:`UsersManual` for details.
39 int *a = (int*)malloc(40);
42 int main() { bad_foo(); }
44 # Ignore reports from bad_foo function.
46 $ clang -fsanitize=address foo.c ; ./a.out
47 # AddressSanitizer prints an error report.
48 $ clang -fsanitize=address -fsanitize-blacklist=blacklist.txt foo.c ; ./a.out
49 # No error report here.
54 Blacklists consist of entries, optionally grouped into sections. Empty lines and
55 lines starting with "#" are ignored.
57 Section names are regular expressions written in square brackets that denote
58 which sanitizer the following entries apply to. For example, ``[address]``
59 specifies AddressSanitizer while ``[cfi-vcall|cfi-icall]`` specifies Control
60 Flow Integrity virtual and indirect call checking. Entries without a section
61 will be placed under the ``[*]`` section applying to all enabled sanitizers.
63 Entries contain an entity type, followed by a colon and a regular expression,
64 specifying the names of the entities, optionally followed by an equals sign and
65 a tool-specific category, e.g. ``fun:*ExampleFunc=example_category``. The
66 meaning of ``*`` in regular expression for entity names is different - it is
67 treated as in shell wildcarding. Two generic entity types are ``src`` and
68 ``fun``, which allow users to specify source files and functions, respectively.
69 Some sanitizer tools may introduce custom entity types and categories - refer to
74 # Lines starting with # are ignored.
75 # Turn off checks for the source file (use absolute path or path relative
76 # to the current working directory):
77 src:/path/to/source/file.c
78 # Turn off checks for a particular functions (use mangled names):
81 # Extended regular expressions are supported:
84 # Shell like usage of * is supported (* is treated as .*):
87 # Specific sanitizer tools may introduce categories.
88 src:/special/path/*=special_sources
89 # Sections can be used to limit blacklist entries to specific sanitizers
92 # Section names are regular expressions
95 # Entries without sections are placed into [*] and apply to all sanitizers