[libomptarget] Fix a race condition in checkDeviceAndCtors
When multiple threads invoke checkDeviceAndCtors, both of them may read true from the shared variable Device.HasPendingGlobals, and then invoke initLibrary redundantly. Therefore only protecting the access to Device.HasPendingGlobals is not sufficient to guarantee that initLibrary is invoked just once. To fix this race condition, we move the invocation of initLibrary into the critical section, and remove the same lock inside initLibrary. Differential Revision: https://reviews.llvm.org/D136952
parent
af91b193
Please register or sign in to comment