@@ -48,9 +48,20 @@ void DescribeThread(AsanThreadContext *context) {
4848 return ;
4949 }
5050 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+
5162 InternalScopedString str;
5263 str.AppendF (" Thread %s" , AsanThreadIdAndName (context).c_str ());
53- if (context-> parent_tid == kInvalidTid ) {
64+ if (!parent_context ) {
5465 str.Append (" created by unknown thread\n " );
5566 Printf (" %s" , str.data ());
5667 return ;
@@ -60,11 +71,8 @@ void DescribeThread(AsanThreadContext *context) {
6071 Printf (" %s" , str.data ());
6172 StackDepotGet (context->stack_id ).Print ();
6273 // 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 )
6675 DescribeThread (parent_context);
67- }
6876}
6977
7078// Shadow descriptions
0 commit comments