Skip to content

Commit 2725ced

Browse files
authored
Merge pull request #791 from compnerd/atomic-memset
shims: fix a subtle bug in semaphore initialisation on Windows
2 parents 0180b4e + df7fa52 commit 2725ced

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/shims/lock.c

+1
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ void _dispatch_sema4_init(_dispatch_sema4_t *sema, int policy DISPATCH_UNUSED)
266266

267267
// lazily allocate the semaphore port
268268

269+
os_atomic_cmpxchg(sema, *sema, 0, relaxed);
269270
while (!dispatch_assume(tmp = CreateSemaphore(NULL, 0, LONG_MAX, NULL))) {
270271
_dispatch_temporary_resource_shortage();
271272
}

0 commit comments

Comments
 (0)