[compiler-rt] [rtsan] Only print out unique stack traces (PR #110028)

Chris Apple via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 11:30:29 PDT 2024


================
@@ -49,7 +50,21 @@ static auto OnViolationAction(DiagnosticsInfo info) {
   return [info]() {
     IncrementTotalErrorCount();
 
-    PrintDiagnostics(info);
+    BufferedStackTrace stack;
+    stack.Unwind(info.pc, info.bp, nullptr,
+                 /*request_fast*/ true);
+
+    StackDepotHandle handle = StackDepotPut_WithHandle(stack);
+
+    const bool is_stack_novel = handle.use_count() == 0;
+    if (UNLIKELY(is_stack_novel)) {
----------------
cjappl wrote:

In a well behaved program we expect 0.

Programs with >=1 issue with halt_on_error=true, we expect exactly one (then we die) - this is the default behavior with default flags

Programs with >=1 issue, with halt_on_error=false, when the [[nonblocking]] code is called in a loop/callback (very typical in real-time programming), we expect it to be called very often. The longer the program runs, the smaller proportion the unique calls will take up (first time through the loop will be all unique, then every loop after will be almost all duplicates when the user hits similar errors)

Happy to remove this in a follow up if you want, I defer to your judgement. I think the nature of real-time code being highly repetitive led me to UNLIKELY here

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


More information about the llvm-commits mailing list