Skip to content

Conversation

@cjappl
Copy link
Contributor

@cjappl cjappl commented Nov 21, 2024

These functions recently were helpful for a user, so I decided to add them to the official docs.

Any feedback on wording or content appreciated as always

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Nov 21, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 21, 2024

@llvm/pr-subscribers-clang

Author: Chris Apple (cjappl)

Changes

These functions recently were helpful for a user, so I decided to add them to the official docs.

Any feedback on wording or content appreciated as always


Full diff: https://github.com/llvm/llvm-project/pull/117086.diff

1 Files Affected:

  • (modified) clang/docs/RealtimeSanitizer.rst (+38)
diff --git a/clang/docs/RealtimeSanitizer.rst b/clang/docs/RealtimeSanitizer.rst
index 193f5217c1a1a1..5431e38fea62ec 100644
--- a/clang/docs/RealtimeSanitizer.rst
+++ b/clang/docs/RealtimeSanitizer.rst
@@ -203,6 +203,44 @@ Some issues with flags can be debugged using the ``verbosity=$NUM`` flag:
    misspelled_flag
    ...
 
+Additional customization
+------------------------
+
+In addition to ``__rtsan_default_options`` outlined above, you can provide definitions of other functions that affect how RTSan operates.
+
+To be notified on every error reported by RTsan, provide a definition of ``__sanitizer_report_error_summary``.
+
+.. code-block:: c
+
+   extern "C" void __sanitizer_report_error_summary(const char *error_summary) {
+      fprintf(stderr, "%s %s\n", "In custom handler! ", error_summary);
+      /* do other custom things */
+   }
+
+The error summary will be of the form: 
+
+.. code-block:: console
+
+   SUMMARY: RealtimeSanitizer: unsafe-library-call main.cpp:8 in process(std::__1::vector<int, std::__1::allocator<int>>&)
+
+To register a callback which will be invoked before a RTSan kills the process:
+
+.. code-block:: c
+
+  extern "C" void __sanitizer_set_death_callback(void (*callback)(void));
+
+  void custom_on_die_callback() {
+    fprintf(stderr, "In custom handler!")
+    /* do other custom things */
+  }
+
+  int main()
+  {
+    __sanitizer_set_death_callback(custom_on_die_callback);
+    ...
+  }
+
+
 Disabling and suppressing
 -------------------------
 

@cjappl cjappl merged commit a12e79a into llvm:main Nov 21, 2024
11 checks passed
@cjappl cjappl deleted the docs_update branch November 21, 2024 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants