Cygwin has a custom implementation of swift_once because the compiler only reserves a single word for the "predicate". However, that implementation (in stdlib/public/runtime/CygwinPort.cpp) has a race condition:
Thread A calls swift_once
Thread B calls swift_once
Thread A reads 0 from the predicate
Thread A stores 1 into the predicate
Thread B reads 1 from the predicate
Thread B returns (!!)
Thread A executes the initialization
There are really three states here: not-yet-run, running, and already-run.
The text was updated successfully, but these errors were encountered:
Additional Detail from JIRA
md5: 97f5aae70837cdc3a6fe66c2376dd77e
Issue Description:
Cygwin has a custom implementation of swift_once because the compiler only reserves a single word for the "predicate". However, that implementation (in stdlib/public/runtime/CygwinPort.cpp) has a race condition:
Thread A calls swift_once
Thread B calls swift_once
Thread A reads 0 from the predicate
Thread A stores 1 into the predicate
Thread B reads 1 from the predicate
Thread B returns (!!)
Thread A executes the initialization
There are really three states here: not-yet-run, running, and already-run.
The text was updated successfully, but these errors were encountered: