@@ -48,9 +48,20 @@ void DescribeThread(AsanThreadContext *context) {
48
48
return ;
49
49
}
50
50
context->announced = true ;
51
+
52
+ AsanThreadContext *parent_context =
53
+ context->parent_tid == kInvalidTid
54
+ ? nullptr
55
+ : GetThreadContextByTidLocked (context->parent_tid );
56
+
57
+ // `context->parent_tid` may point to reused slot. Check `unique_id` which
58
+ // is always smaller for the parent, always greater for a new user.
59
+ if (context->unique_id <= parent_context->unique_id )
60
+ parent_context = nullptr ;
61
+
51
62
InternalScopedString str;
52
63
str.AppendF (" Thread %s" , AsanThreadIdAndName (context).c_str ());
53
- if (context-> parent_tid == kInvalidTid ) {
64
+ if (!parent_context ) {
54
65
str.Append (" created by unknown thread\n " );
55
66
Printf (" %s" , str.data ());
56
67
return ;
@@ -60,11 +71,8 @@ void DescribeThread(AsanThreadContext *context) {
60
71
Printf (" %s" , str.data ());
61
72
StackDepotGet (context->stack_id ).Print ();
62
73
// Recursively described parent thread if needed.
63
- if (flags ()->print_full_thread_history ) {
64
- AsanThreadContext *parent_context =
65
- GetThreadContextByTidLocked (context->parent_tid );
74
+ if (flags ()->print_full_thread_history )
66
75
DescribeThread (parent_context);
67
- }
68
76
}
69
77
70
78
// Shadow descriptions
0 commit comments