Skip to content

[asan] Prevent printing invalid parent thread #111916

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

Conversation

vitalybuka
Copy link
Collaborator

By default reuse can happend only after
UINT32_MAX threads, so it's almost NFC.

Created using spr 1.3.4
@llvmbot
Copy link
Member

llvmbot commented Oct 10, 2024

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

Author: Vitaly Buka (vitalybuka)

Changes

By default reuse can happend only after
UINT32_MAX threads, so it's almost NFC.


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

1 Files Affected:

  • (modified) compiler-rt/lib/asan/asan_descriptions.cpp (+4-1)
diff --git a/compiler-rt/lib/asan/asan_descriptions.cpp b/compiler-rt/lib/asan/asan_descriptions.cpp
index 1c2f20a76343bb..778e134f1cf2a5 100644
--- a/compiler-rt/lib/asan/asan_descriptions.cpp
+++ b/compiler-rt/lib/asan/asan_descriptions.cpp
@@ -63,7 +63,10 @@ void DescribeThread(AsanThreadContext *context) {
   if (flags()->print_full_thread_history) {
     AsanThreadContext *parent_context =
         GetThreadContextByTidLocked(context->parent_tid);
-    DescribeThread(parent_context);
+    // `context->parent_tid` may point to reused slot, double check, `unique_id`
+    // of new user will always be greater then the child.
+    if (context->unique_id > parent_context->unique_id)
+      DescribeThread(parent_context);
   }
 }
 

@fmayer
Copy link
Contributor

fmayer commented Oct 10, 2024

Do we want to print something? It might be confusing why the thread description is missing

Created using spr 1.3.4
Created using spr 1.3.4
@vitalybuka
Copy link
Collaborator Author

Do we want to print something? It might be confusing why the thread description is missing

Done

@vitalybuka vitalybuka merged commit 9c81a24 into main Oct 11, 2024
7 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/asan-prevent-printing-invalid-parent-thread branch October 11, 2024 00:44
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
By default reuse can happend only after
`UINT32_MAX` threads, so it's almost NFC.
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.

3 participants