[clang] [NFC][rtsan] Update docs to include [[clang::blocking]] (PR #111249)

via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 5 13:26:33 PDT 2024


================
@@ -58,31 +58,71 @@ code.
      return 0;
    }
    # Compile and link
-   % clang++ -fsanitize=realtime -g example_realtime_violation.cpp
+   % clang++ -fsanitize=realtime example_realtime_violation.cpp
 
 If a real-time safety violation is detected in a ``[[clang::nonblocking]]``
 context, or any function invoked by that function, the program will exit with a
 non-zero exit code.
 
 .. code-block:: console
 
-   % clang++ -fsanitize=realtime -g example_realtime_violation.cpp
+   % clang++ -fsanitize=realtime example_realtime_violation.cpp
    % ./a.out
-   Real-time violation: intercepted call to real-time unsafe function `malloc` in real-time context! Stack trace:
-    #0 0x000102893034 in __rtsan::PrintStackTrace() rtsan_stack.cpp:45
-    #1 0x000102892e64 in __rtsan::Context::ExpectNotRealtime(char const*) rtsan_context.cpp:78
-    #2 0x00010289397c in malloc rtsan_interceptors.cpp:286
-    #3 0x000195bd7bd0 in operator new(unsigned long)+0x1c (libc++abi.dylib:arm64+0x16bd0)
-    #4 0x5c7f00010230f07c  (<unknown module>)
-    #5 0x00010230f058 in std::__1::__libcpp_allocate[abi:ue170006](unsigned long, unsigned long) new:324
-    #6 0x00010230effc in std::__1::allocator<float>::allocate[abi:ue170006](unsigned long) allocator.h:114
-    ... snip ...
-    #10 0x00010230e4bc in std::__1::vector<float, std::__1::allocator<float>>::__append(unsigned long) vector:1162
-    #11 0x00010230dcdc in std::__1::vector<float, std::__1::allocator<float>>::resize(unsigned long) vector:1981
-    #12 0x00010230dc28 in violation() main.cpp:5
-    #13 0x00010230dd64 in main main.cpp:9
-    #14 0x0001958960dc  (<unknown module>)
-    #15 0x2f557ffffffffffc  (<unknown module>)
+   ==76290==ERROR: RealtimeSanitizer: unsafe-library-call
+   Intercepted call to real-time unsafe function `malloc` in real-time context!
+       #0 0x000102a7b884 in malloc rtsan_interceptors.cpp:426
+       #1 0x00019c326bd0 in operator new(unsigned long)+0x1c (libc++abi.dylib:arm64+0x16bd0)
+       #2 0xa30d0001024f79a8  (<unknown module>)
+       #3 0x0001024f794c in std::__1::__libcpp_allocate[abi:ne200000](unsigned long, unsigned long)+0x44
+       #4 0x0001024f78c4 in std::__1::allocator<float>::allocate[abi:ne200000](unsigned long)+0x44
+       ... snip ...
+       #9 0x0001024f6868 in std::__1::vector<float, std::__1::allocator<float>>::resize(unsigned long)+0x48
+       #10 0x0001024f67b4 in violation()+0x24
+       #11 0x0001024f68f0 in main+0x18 (a.out:arm64+0x1000028f0)
+       #12 0x00019bfe3150  (<unknown module>)
+       #13 0xed5efffffffffffc  (<unknown module>)
+
+
+Blocking functions
+------------------
+
+Calls to system library functions such as ``malloc`` are automatically caught by
+RealtimeSanitizer. Real-time programmers may also write their own blocking
+(real-time unsafe) functions that they wish RealtimeSanitizer to be aware of.
+RealtimeSanitizer will raise an error if any function attributed with
----------------
davidtrevelyan wrote:

Agreed - "at run time" is a good addition - thanks

https://github.com/llvm/llvm-project/pull/111249


More information about the cfe-commits mailing list