[PATCH] D45398: Fix lock order inversion between ManagedStatic and Statistic

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 12 11:12:06 PDT 2018


inglorion marked an inline comment as done.
inglorion added inline comments.


================
Comment at: llvm/lib/Support/Statistic.cpp:97
   // printed.
-  sys::SmartScopedLock<true> Writer(*StatLock);
+  // There is a possible lock order inversion here. llvm_shutdown calls us
+  // while holding the ManagedStatic mutex. If we take StatLock and call
----------------
dsanders wrote:
> Are you sure llvm_shutdown() calls Statistic::RegisterStatistic()? It's surprising that it would be constructing and registering new Statistic objects in a function that's intended to destroy them.
Ah, not RegisterStatic, but PrintStatistics. I had intended "us" to mean "functions in this part of the code", but seeing that that wasn't clear, I've changed the comment.


https://reviews.llvm.org/D45398





More information about the llvm-commits mailing list