Closed Bug 1406793 Opened 3 years ago Closed 3 years ago
Windows Version Or Later/Is Windows Build Or Later/Is Windows10Build Or Later aren't thread safe
59 bytes, text/x-review-board-request
IsWindowsBuildOrLater and IsWindows10BuildOrLater store previous results (to speed up future access I guess) in static variables. Both IsWindows10BuildOrLater and IsWindows10BuildOrLater are called from various threads. There's no locking mechanism to protect the way those results are stored or access.
How does it matter? The worst that can happen is that the function code runs twice, gets the same value twice, and stores the same value twice.
The writes being non atomic, if you have simultaneous write access to the variable, the result is undefined. As such, the result of the next run is also undefined. Of all people, data races should always be a concern.
Thanks David for fixing the reviewer...
Comment on attachment 8916538 [details] Bug 1406793 - Make IsWindows* methods thread-safe. https://reviewboard.mozilla.org/r/187674/#review192870 If this was cross-platform code, I think I would care a little more about efficiency, but since this is Windows-only and we'll always be executing on x86, where sequentially consistent atomics are less of a problem (particularly for loads, which is what matters here), I think this is OK.
Attachment #8916538 - Flags: review?(nfroyd) → review+
Comment on attachment 8916538 [details] Bug 1406793 - Make IsWindows* methods thread-safe. https://reviewboard.mozilla.org/r/187674/#review192870 thanks for the review. im interested to know however, how you could make this more efficient on other platforms. as it, the code quickly settle in a state wheremthe first two comparisons handle all cases, and the main code never runs
Pushed by email@example.com: https://hg.mozilla.org/integration/autoland/rev/4bf0f40c6755 Make IsWindows* methods thread-safe. r=froydnj
You need to log in before you can comment on or make changes to this bug.