The function assumes that __kmp_gtid_get_specific always returns a valid gtid.
That is not always true, because when creating the key for thread-specific data,
a destructor is assigned. The dtor will be called at thread exit. However, before
the dtor is called, the thread-specific data will be reset to NULL first
(https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_key_create.html):
At thread exit, if a key value has a non-NULL destructor pointer, and the thread
has a non-NULL value associated with that key, the value of the key is set to NULL.
This will lead to that __kmp_gtid_get_specific returns KMP_GTID_DNE.