[compiler-rt] 6c9256d - [ASAN] fix a nullptr dereference error. (#116011)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 13 15:47:00 PST 2024
Author: Wu Yingcong
Date: 2024-11-13T15:46:57-08:00
New Revision: 6c9256dc5cda9184e295bc8d00be35e61b3be892
URL: https://github.com/llvm/llvm-project/commit/6c9256dc5cda9184e295bc8d00be35e61b3be892
DIFF: https://github.com/llvm/llvm-project/commit/6c9256dc5cda9184e295bc8d00be35e61b3be892.diff
LOG: [ASAN] fix a nullptr dereference error. (#116011)
`parent_context` is used without checking for nullptr and we can see in
LINE 50 that it could totally be nullptr. This patch addresses this
issue.
Added:
Modified:
compiler-rt/lib/asan/asan_descriptions.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/asan/asan_descriptions.cpp b/compiler-rt/lib/asan/asan_descriptions.cpp
index caec79313e22ff..c9f3e4d682d959 100644
--- a/compiler-rt/lib/asan/asan_descriptions.cpp
+++ b/compiler-rt/lib/asan/asan_descriptions.cpp
@@ -45,6 +45,9 @@ void DescribeThread(AsanThreadContext *context) {
}
context->announced = true;
+ InternalScopedString str;
+ str.AppendF("Thread %s", AsanThreadIdAndName(context).c_str());
+
AsanThreadContext *parent_context =
context->parent_tid == kInvalidTid
? nullptr
@@ -52,12 +55,7 @@ void DescribeThread(AsanThreadContext *context) {
// `context->parent_tid` may point to reused slot. Check `unique_id` which
// is always smaller for the parent, always greater for a new user.
- if (context->unique_id <= parent_context->unique_id)
- parent_context = nullptr;
-
- InternalScopedString str;
- str.AppendF("Thread %s", AsanThreadIdAndName(context).c_str());
- if (!parent_context) {
+ if (!parent_context || context->unique_id <= parent_context->unique_id) {
str.Append(" created by unknown thread\n");
Printf("%s", str.data());
return;
More information about the llvm-commits
mailing list