Skip to content

Commit a93c952

Browse files
authored
[rtsan][NFC] Documentation of suppression flag (#112727)
1 parent 1bc2cd9 commit a93c952

File tree

1 file changed

+64
-4
lines changed

1 file changed

+64
-4
lines changed

clang/docs/RealtimeSanitizer.rst

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ A **partial** list of flags RealtimeSanitizer respects:
183183
- ``true``
184184
- boolean
185185
- If set, use the symbolizer to turn virtual addresses to file/line locations. If false, can greatly speed up the error reporting.
186+
* - ``suppressions``
187+
- ""
188+
- path
189+
- If set to a valid suppressions file, will suppress issue reporting. See details in "Disabling", below.
186190

187191

188192
Some issues with flags can be debugged using the ``verbosity=$NUM`` flag:
@@ -194,12 +198,43 @@ Some issues with flags can be debugged using the ``verbosity=$NUM`` flag:
194198
misspelled_flag
195199
...
196200
197-
Disabling
198-
---------
201+
Disabling and suppressing
202+
-------------------------
199203

200-
In some circumstances, you may want to suppress error reporting in a specific scope.
204+
There are multiple ways to disable error reporting when using RealtimeSanitizer.
201205

202-
In C++, this is achieved via ``__rtsan::ScopedDisabler``. Within the scope where the ``ScopedDisabler`` object is instantiated, all sanitizer error reports are suppressed. This suppression applies to the current scope as well as all invoked functions, including any functions called transitively.
206+
In general, ``ScopedDisabler`` should be preferred, as it is the most performant.
207+
208+
.. list-table:: Suppression methods
209+
:widths: 30 15 15 10 70
210+
:header-rows: 1
211+
212+
* - Method
213+
- Specified at?
214+
- Scope
215+
- Run-time cost
216+
- Description
217+
* - ``ScopedDisabler``
218+
- Compile-time
219+
- Stack
220+
- Very low
221+
- Violations are ignored for the lifetime of the ``ScopedDisabler`` object.
222+
* - ``function-name-matches`` suppression
223+
- Run-time
224+
- Single function
225+
- Medium
226+
- Suppresses intercepted and ``[[clang::blocking]]`` function calls by name.
227+
* - ``call-stack-contains`` suppression
228+
- Run-time
229+
- Stack
230+
- High
231+
- Suppresses any stack trace contaning the specified pattern.
232+
233+
234+
``ScopedDisabler``
235+
##################
236+
237+
At compile time, RealtimeSanitizer may be disabled using ``__rtsan::ScopedDisabler``. RTSan ignores any errors originating within the ``ScopedDisabler`` instance variable scope.
203238

204239
.. code-block:: c++
205240

@@ -233,6 +268,31 @@ In C, you can use the ``__rtsan_disable()`` and ``rtsan_enable()`` functions to
233268

234269
Each call to ``__rtsan_disable()`` must be paired with a subsequent call to ``__rtsan_enable()`` to restore normal sanitizer functionality. If a corresponding ``rtsan_enable()`` call is not made, the behavior is undefined.
235270

271+
Suppression file
272+
################
273+
274+
At run-time, suppressions may be specified using a suppressions file passed in ``RTSAN_OPTIONS``. Run-time suppression may be useful if the source cannot be changed.
275+
276+
.. code-block:: console
277+
278+
> cat suppressions.supp
279+
call-stack-contains:MallocViolation
280+
call-stack-contains:std::*vector
281+
function-name-matches:free
282+
function-name-matches:CustomMarkedBlocking*
283+
> RTSAN_OPTIONS="suppressions=suppressions.supp" ./a.out
284+
...
285+
286+
Suppressions specified in this file are one of two flavors.
287+
288+
``function-name-matches`` suppresses reporting of any intercepted library call, or function marked ``[[clang::blocking]]`` by name. If, for instance, you know that ``malloc`` is real-time safe on your system, you can disable the check for it via ``function-name-matches:malloc``.
289+
290+
``call-stack-contains`` suppresses reporting of errors in any stack that contains a string matching the pattern specified. For example, suppressing error reporting of any non-real-time-safe behavior in ``std::vector`` may be specified ``call-stack-contains:std::*vector``. You must include symbols in your build for this method to be effective, unsymbolicated stack traces cannot be matched. ``call-stack-contains`` has the highest run-time cost of any method of suppression.
291+
292+
Patterns may be exact matches or are "regex-light" patterns, containing special characters such as ``^$*``.
293+
294+
The number of potential errors suppressed via this method may be seen on exit when using the ``print_stats_on_exit`` flag.
295+
236296
Compile-time sanitizer detection
237297
--------------------------------
238298

0 commit comments

Comments
 (0)