Skip to content

[asan] Print unique_id instead of tid #111925

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

Merged

Conversation

vitalybuka
Copy link
Collaborator

Before the first reuse, after 2^32 threads
they are equal.

@llvmbot
Copy link
Member

llvmbot commented Oct 10, 2024

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

Author: Vitaly Buka (vitalybuka)

Changes

Before the first reuse, after 2^32 threads
they are equal.


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

1 Files Affected:

  • (modified) compiler-rt/lib/asan/asan_descriptions.cpp (+1-1)
diff --git a/compiler-rt/lib/asan/asan_descriptions.cpp b/compiler-rt/lib/asan/asan_descriptions.cpp
index db87789aea86a0..caec79313e22ff 100644
--- a/compiler-rt/lib/asan/asan_descriptions.cpp
+++ b/compiler-rt/lib/asan/asan_descriptions.cpp
@@ -24,7 +24,7 @@ AsanThreadIdAndName::AsanThreadIdAndName(AsanThreadContext *t) {
     internal_snprintf(name, sizeof(name), "T-1");
     return;
   }
-  int len = internal_snprintf(name, sizeof(name), "T%d", t->tid);
+  int len = internal_snprintf(name, sizeof(name), "T%llu", t->unique_id);
   CHECK(((unsigned int)len) < sizeof(name));
   if (internal_strlen(t->name))
     internal_snprintf(&name[len], sizeof(name) - len, " (%s)", t->name);

@vitalybuka vitalybuka requested a review from fmayer October 10, 2024 23:46
@fmayer
Copy link
Contributor

fmayer commented Oct 10, 2024

Is this an improvement? How will people convert this to the TID, or know that they have to?

Created using spr 1.3.4

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

Is this an improvement? How will people convert this to the TID, or know that they have to?

TID is not OS ID, TID is just an index in ThreadRegistry array
I think it's not perfect, and we need to replace/add this with OS ID, but it's bigger job.

Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
@vitalybuka vitalybuka changed the base branch from users/vitalybuka/spr/main.asan-print-unique_id-instead-of-tid to main October 11, 2024 04:04
@vitalybuka vitalybuka merged commit df4c913 into main Oct 11, 2024
7 of 9 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/asan-print-unique_id-instead-of-tid branch October 11, 2024 04:04
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
Before the first reuse, after 2^32 threads
they are equal.
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