LifoSem Mem Pool: Avoid deadlock during static initialization
Summary: There is probably a better solution than this, but wanted to publish this diff to point out the issue. If DeterministicSchedule has been initialize befored the first invocation of LifoSemRawNode<DeterministicAtomic>::pool(), the thread invoking LifoSemRawNode<DeterminsiticAtomic> will enter __cxa_guard_acquire and the DeterministicAtomic constructor. Implementations of DeterminsticAtomic may be modified to use DeterministicSchedule::beforeSharedAccess() in the constructor, which will deadlock if a second thread invokes LifoSemRawNode<DeterministicAtomic>::pool() before the first thread is rescheduled. For example, BufferedAtomic requires shared access during the constructor. Reviewed By: yfeldblum Differential Revision: D10478693 fbshipit-source-id: eeb09be9ad0fa06c0bb957fff4d56d120b31c6ee
Showing
Please register or sign in to comment