[PATCH] Remove support for runtime multithreading

Zachary Turner zturner at google.com
Fri Jun 13 12:03:52 PDT 2014


================
Comment at: lib/Support/ErrorHandling.cpp:70-80
@@ -65,3 +69,13 @@
 void llvm::report_fatal_error(const Twine &Reason, bool GenCrashDiag) {
-  if (ErrorHandler) {
-    ErrorHandler(ErrorHandlerUserData, Reason.str(), GenCrashDiag);
+  llvm::fatal_error_handler_t handler = nullptr;
+  void* handlerData = nullptr;
+  {
+    // 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);
+    handler = ErrorHandler;
+    handlerData = ErrorHandlerUserData;
+  }
+
----------------
Chandler Carruth wrote:
> All of this feels like a totally separate thing from removing the runtime control of multithreading.
> 
> Can you try to split this up into more isolated changes? I feel like this is still a combined patch of several things that really should be submitted independently.
Fair enough.  Although if I'm going to do it that way, the error handling functions have to be made thread-safe first, and then the removal of llvm_start / stop multithreading changes have to go in second.  Which is fine, so I'll do that.

================
Comment at: lib/Support/ErrorHandling.cpp:74
@@ +73,3 @@
+    // 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
----------------
Ed Maste wrote:
> To be pedantic, all implementations exhibit undefined behaviour if a mutex destroyed while owned, although the nature of that behavior may be different.
> 
I'm actually submitting this *before* converting to std::*mutex though.  Our own mutex implementation doesn't exhibit undefined behavior.  std::mutex implementations do though.

http://reviews.llvm.org/D4139






More information about the llvm-commits mailing list