[Lldb-commits] [PATCH] D131081: [lldb] Prevent race condition when fetching /proc/cpuinfo

walter erquinigo via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 4 10:40:12 PDT 2022


wallace added inline comments.


================
Comment at: lldb/source/Plugins/Process/Linux/Procfs.cpp:12
 #include "lldb/Host/linux/Support.h"
+
 #include "llvm/Support/MemoryBuffer.h"
----------------
labath wrote:
> btw, llvm does not generally put blank lines between include headers. omitting those lets clang format reorder everything according to the [[ https://llvm.org/docs/CodingStandards.html#include-style | official style ]].
oh, i didn't know that clang-format ensures that style guideline. Thanks!


================
Comment at: lldb/source/Plugins/Process/Linux/Procfs.cpp:22-26
+  static Optional<ErrorOr<std::unique_ptr<MemoryBuffer>>> cpu_info_or_err;
+  static llvm::once_flag g_once_flag;
+
+  llvm::call_once(g_once_flag,
+                  [] { cpu_info_or_err = getProcFile("cpuinfo"); });
----------------
labath wrote:
> And why not this?
i didn't know that local static initializations are ensured by the compiler not to have race conditions. TIL
I'll just do what you are suggesting here


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131081/new/

https://reviews.llvm.org/D131081



More information about the lldb-commits mailing list