mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 13:50:11 +00:00
[OpenMP] Fix a segment fault in __kmp_get_global_thread_id
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. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D159324
This commit is contained in:
parent
ef8121b109
commit
35fdf8d703
@ -196,6 +196,12 @@ int __kmp_get_global_thread_id() {
|
||||
if (i < 0)
|
||||
return i;
|
||||
|
||||
// other_threads[i] can be nullptr at this point because the corresponding
|
||||
// thread could have already been destructed. It can happen when this function
|
||||
// is called in end library routine.
|
||||
if (!TCR_SYNC_PTR(other_threads[i]))
|
||||
return i;
|
||||
|
||||
/* dynamically updated stack window for uber threads to avoid get_specific
|
||||
call */
|
||||
if (!TCR_4(other_threads[i]->th.th_info.ds.ds_stackgrow)) {
|
||||
|
Loading…
Reference in New Issue
Block a user