@clayborg found a potential race condition when setting a static
variable. The fix seems simply to use call_once.
All relevant tests pass.
Differential D131081
[lldb] Prevent race condition when fetching /proc/cpuinfo wallace on Aug 3 2022, 10:01 AM. Authored by
Details @clayborg found a potential race condition when setting a static All relevant tests pass.
Diff Detail
Event Timeline
Comment Actions It's not clear to me why you're insisting on call_once, when c++ guarantees that the function-local statics will only be initialized once (atomically). And with the new version, we don't even need the lambda..
Comment Actions I tend to use call_once to avoid an issue, IIRC, that older windows compilers had with the "statics will only be initialized once (atomically)". I seem to remember Microsoft compilers were not fully compliant with this and that it could cause multi-threading issues, but I don't know if this has been fixed or if this wouldn't be an issue in this case. Comment Actions That's important to know. At least in this case this code only runs on Linux, so hopefully we are good with the atomic static initialization. |
btw, llvm does not generally put blank lines between include headers. omitting those lets clang format reorder everything according to the official style.