This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Fix a segment fault in __kmp_get_global_thread_id
ClosedPublic

Authored by tianshilei1992 on Aug 31 2023, 6:09 PM.

Details

Summary

In __kmp_get_global_thread_id, if the gtid mode is 1, after getting the gtid
from TLS, it will store the gtid value to the thread stack maintained in the thread
descriptor. However, __kmp_get_global_thread_id can be called when the library
is destructed, after the corresponding thread info has been release. This will
cause a segment fault. This can happen on an Intel-based Mac.

Diff Detail

Event Timeline

tianshilei1992 created this revision.Aug 31 2023, 6:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2023, 6:09 PM
tianshilei1992 requested review of this revision.Aug 31 2023, 6:09 PM
Herald added a project: Restricted Project. · View Herald Transcript

improve comment

jdoerfert accepted this revision.Aug 31 2023, 6:11 PM

can we have a test?

This revision is now accepted and ready to land.Aug 31 2023, 6:11 PM

can we have a test?

It can be exposed by existing test on macOS. That's how I found the issue. This *might* cause the issue reported in https://github.com/llvm/llvm-project/issues/63194.