[TSan] Unlock fastpath when checking domains_to_finalize
I understand that the affected line is a fastpath which seems absolutely fine to me as it is properly checked later. It is, however, rightfully, detected as a data race by Clang's ThreadSanitizer. I would, therefore, suggest using `UnlockedReadPointer ()` to mark this race as known + accepted.
#include <mono/utils/mono-coop-semaphore.h>
#include <mono/utils/hazard-pointer.h>
#include <mono/utils/w32api.h>
+#include <mono/utils/unlocked.h>
#ifndef HOST_WIN32
#include <pthread.h>
DomainFinalizationReq *req = NULL;
MonoDomain *domain;
- if (domains_to_finalize) {
+ if (UnlockedReadPointer ((gpointer)&domains_to_finalize)) {
mono_finalizer_lock ();
if (domains_to_finalize) {
req = (DomainFinalizationReq *)domains_to_finalize->data;
return *src;
}
+MONO_UNLOCKED_ATTRS
+gpointer
+UnlockedReadPointer (volatile gpointer *src)
+{
+ return *src;
+}
+
#endif /* _UNLOCKED_H_ */