From 7ad122f90efabec3361d8509f2e6cf5e953cda5d Mon Sep 17 00:00:00 2001 From: Antoine Hoarau <703240+ahoarau@users.noreply.github.com> Date: Thu, 20 Nov 2025 17:04:09 +0100 Subject: [PATCH 1/3] add rtsan section --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index 06ba965..cf3c142 100644 --- a/README.md +++ b/README.md @@ -473,3 +473,50 @@ awk 1 0 0 10 SUM: 2299 48299 38039 271157 -------------------------------------------------------------------------------- ``` + +# Realtime Sanitizer (RTSan) + +Allows to detect any non-deterministic behavior in a piece of code, like dynamic allocations, mutex locks, systems calls etc. +It comes with `clang-20`, but with a bit of effort can be user in older versions and GCC with the standalone project (ref below). +besically all you need to do is add the function attribute `[[clang::nonblocking]]` in your function and compile with `-fsanitize=realtime`. + +The `Function Effect Analysis` is a sister project that can detect those in compile-time, where the sanitizers are runtime-only. +To get compile-time analysis, compile with `-Wfunction-effects`. + +`a.cpp` +```c++ +void f() [[clang::nonblocking]] { + std::vector v; + v.push_back(1); +} + +int main() { + f(); + return 0; +} +``` +`CMakeLists.txt` +```cmake +cmake_minimum_required(VERSION 3.22) +project(a) +add_executable(a a.cpp) +target_compile_options(a PRIVATE -Werror=function-effects) # compile-time checks +target_compile_options(a PRIVATE -fsanitize=realtime) # runtime checks +target_link_options(a PRIVATE -fsanitize=realtime) # runtime checks +``` + +Try online: https://godbolt.org/z/ozYGc63rE + +refs: + +LLVM’s Real-Time Safety Revolution: +https://www.youtube.com/watch?v=b_hd5FAv1dw + +Standalone RTSan (devmode): https://github.com/realtime-sanitizer/rtsan + +Official documentation: +https://clang.llvm.org/docs/RealtimeSanitizer.html + +https://clang.llvm.org/docs/FunctionEffectAnalysis.html + + From 6132ee5cb9764aa02023d9d537e2b6e0cd3a3ea6 Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Sat, 22 Nov 2025 19:13:39 +0100 Subject: [PATCH 2/3] Fix typos --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cf3c142..1830c9f 100644 --- a/README.md +++ b/README.md @@ -477,8 +477,8 @@ SUM: 2299 48299 38039 271157 # Realtime Sanitizer (RTSan) Allows to detect any non-deterministic behavior in a piece of code, like dynamic allocations, mutex locks, systems calls etc. -It comes with `clang-20`, but with a bit of effort can be user in older versions and GCC with the standalone project (ref below). -besically all you need to do is add the function attribute `[[clang::nonblocking]]` in your function and compile with `-fsanitize=realtime`. +It comes with `clang-20`, but with a bit of effort can be user in older versions and GCC with the standalone project (see ref below). +Basically, all you need to do is add the function attribute `[[clang::nonblocking]]` in your function and compile with `-fsanitize=realtime`. The `Function Effect Analysis` is a sister project that can detect those in compile-time, where the sanitizers are runtime-only. To get compile-time analysis, compile with `-Wfunction-effects`. @@ -507,7 +507,7 @@ target_link_options(a PRIVATE -fsanitize=realtime) # runtime checks Try online: https://godbolt.org/z/ozYGc63rE -refs: +Referenced: LLVM’s Real-Time Safety Revolution: https://www.youtube.com/watch?v=b_hd5FAv1dw From 01cc9f90efd000bd2e789cb25ba3ab2947f3bbc3 Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Sat, 22 Nov 2025 19:56:49 +0100 Subject: [PATCH 3/3] rtsan: second pass Updated language for clarity and corrected minor typos. --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1830c9f..d263a38 100644 --- a/README.md +++ b/README.md @@ -476,13 +476,14 @@ SUM: 2299 48299 38039 271157 # Realtime Sanitizer (RTSan) -Allows to detect any non-deterministic behavior in a piece of code, like dynamic allocations, mutex locks, systems calls etc. -It comes with `clang-20`, but with a bit of effort can be user in older versions and GCC with the standalone project (see ref below). +Allows detection of any non-deterministic behavior in a piece of code, such as dynamic allocations, mutex locks, and system calls. +It comes with `clang-20`, but with a bit of effort, it can be used with older versions and GCC using the standalone project (see ref below). Basically, all you need to do is add the function attribute `[[clang::nonblocking]]` in your function and compile with `-fsanitize=realtime`. -The `Function Effect Analysis` is a sister project that can detect those in compile-time, where the sanitizers are runtime-only. +The `Function Effect Analysis` is a sister project that can detect such effects at compile-time, whereas sanitizers are runtime-only. To get compile-time analysis, compile with `-Wfunction-effects`. +## Basic exemple `a.cpp` ```c++ void f() [[clang::nonblocking]] { @@ -507,7 +508,7 @@ target_link_options(a PRIVATE -fsanitize=realtime) # runtime checks Try online: https://godbolt.org/z/ozYGc63rE -Referenced: +## References LLVM’s Real-Time Safety Revolution: https://www.youtube.com/watch?v=b_hd5FAv1dw