1515struct ia2_thread_metadata * ia2_all_threads_metadata_get_for_current_thread (struct ia2_all_threads_metadata * const this ) {
1616 const pid_t tid = gettid ();
1717
18- struct ia2_thread_metadata * metadata = NULL ;
1918 if (pthread_mutex_lock (& this -> lock ) != 0 ) {
2019 perror ("pthread_mutex_lock in ia2_all_threads_data_lookup failed" );
21- goto ret ;
20+ abort ();
21+ }
22+
23+ if (this -> num_threads >= array_len (this -> thread_metadata )) {
24+ fprintf (stderr , "created %zu threads, but can't store them all (max is IA2_MAX_THREADS)\n" , this -> num_threads );
25+ abort ();
2226 }
27+
28+ struct ia2_thread_metadata * metadata = NULL ;
2329 for (size_t i = 0 ; i < this -> num_threads ; i ++ ) {
2430 if (this -> tids [i ] == tid ) {
2531 metadata = & this -> thread_metadata [i ];
2632 goto unlock ;
2733 }
2834 }
29- if (this -> num_threads >= array_len (this -> thread_metadata )) {
30- fprintf (stderr , "created %zu threads, but can't store them all (max is IA2_MAX_THREADS)\n" , this -> num_threads );
31- goto unlock ;
32- }
3335
3436 metadata = & this -> thread_metadata [this -> num_threads ];
3537 this -> tids [this -> num_threads ] = tid ;
@@ -38,13 +40,12 @@ struct ia2_thread_metadata *ia2_all_threads_metadata_get_for_current_thread(stru
3840 metadata -> tid = tid ;
3941 metadata -> thread = pthread_self ();
4042
41- goto unlock ;
42-
4343unlock :
4444 if (pthread_mutex_unlock (& this -> lock ) != 0 ) {
4545 perror ("pthread_mutex_unlock in ia2_all_threads_data_lookup failed" );
46+ abort ();
4647 }
47- ret :
48+
4849 return metadata ;
4950}
5051
@@ -112,6 +113,7 @@ static void label_memory_map(FILE *log, uintptr_t start_addr) {
112113 const struct ia2_addr_location location = ia2_addr_location_find (start_addr );
113114 const struct ia2_thread_metadata * metadata = location .thread_metadata ;
114115
116+ // If `location.name` is non-`NULL`, then `location` was found.
115117 if (location .name ) {
116118 Dl_info dl_info = {0 };
117119 const bool has_dl_info = dladdr ((void * )metadata -> start_fn , & dl_info );
0 commit comments