Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tsan] Fallback to top frame #77145

Merged
merged 5 commits into from
Jan 5, 2024

Conversation

vitalybuka
Copy link
Collaborator

@vitalybuka vitalybuka commented Jan 5, 2024

Probably it's not important, as it should not happen often,
but if all frames are internal we should pick top, not
the bottom frame.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 5, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)

Changes

Probably it's not important, as it should not happen,
but if all frames are internal we should pick top, not
the bottom frame.


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

1 Files Affected:

  • (modified) compiler-rt/lib/tsan/rtl/tsan_report.cpp (+5-4)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
index cdcc20b9758f48..c6b764bd891752 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
@@ -275,7 +275,7 @@ static ReportStack *ChooseSummaryStack(const ReportDesc *rep) {
 
 static bool FrameIsInternal(const SymbolizedStack *frame) {
   if (!frame)
-    return false;
+    return true;
   const char *file = frame->info.file;
   const char *module = frame->info.module;
   if (file && (internal_strstr(file, "/compiler-rt/lib/")))
@@ -286,9 +286,10 @@ static bool FrameIsInternal(const SymbolizedStack *frame) {
 }
 
 static SymbolizedStack *SkipTsanInternalFrames(SymbolizedStack *frames) {
-  while (FrameIsInternal(frames) && frames->next)
-    frames = frames->next;
-  return frames;
+  for (SymbolizedStack *f = frames; f; f = f->next)
+    if (!FrameIsInternal(f))
+      return f;
+  return frames;  // Fallback to the top frame.
 }
 
 void PrintReport(const ReportDesc *rep) {

@thurstond
Copy link
Contributor

Probably it's not important, as it should not happen, but if all frames are internal we should pick top, not the bottom frame.

If we encounter a case that "should not happen", wouldn't it be better to fail/assert?

Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
@vitalybuka
Copy link
Collaborator Author

Probably it's not important, as it should not happen, but if all frames are internal we should pick top, not the bottom frame.

If we encounter a case that "should not happen", wouldn't it be better to fail/assert?

usually should not happen
e.g. without symbolizer it can happen

@vitalybuka vitalybuka changed the base branch from users/vitalybuka/spr/main.tsan-fallback-to-top-frame to main January 5, 2024 22:35
Created using spr 1.3.4
@vitalybuka vitalybuka merged commit f74ce00 into main Jan 5, 2024
3 of 4 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/tsan-fallback-to-top-frame branch January 5, 2024 22:48
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
Probably it's not important, as it should not happen often,
but if all frames are internal we should pick top, not
the bottom frame.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants