[PATCH] Make error handling functions thread-safe.

Chandler Carruth chandlerc at gmail.com
Fri Jun 13 14:21:39 PDT 2014

Looks good with a slightly relaxed comment.

Comment at: lib/Support/ErrorHandling.cpp:74-77
@@ +73,6 @@
+  {
+    // The LLVM error handler is likely to call exit(), which should not be done
+    // under a mutex (some mutex implementations exhibit undefined behavior if
+    // destroyed while acquired).  So the mutex is acquired only while reading
+    // the error handler.
+    llvm::MutexGuard Lock(ErrorHandlerMutex);
This comment is a bit too specific IMO. It is never a good idea to call a user provided callback while holding a mutex.


More information about the llvm-commits mailing list