[libcxx-commits] [libcxxabi] 59736ce - [libc++abi] Make the error message for recursive initialization of function-local statics more explicit

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 19 13:18:24 PDT 2023


Author: Louis Dionne
Date: 2023-04-19T16:18:14-04:00
New Revision: 59736ceb8d45ac2a0e7e8b67fa2e067c9f3070ef

URL: https://github.com/llvm/llvm-project/commit/59736ceb8d45ac2a0e7e8b67fa2e067c9f3070ef
DIFF: https://github.com/llvm/llvm-project/commit/59736ceb8d45ac2a0e7e8b67fa2e067c9f3070ef.diff

LOG: [libc++abi] Make the error message for recursive initialization of function-local statics more explicit

The new message is a bit verbose, but it makes it clearer that this isn't
a problem in libc++abi, but instead a problem in the user's code. Otherwise,
we get bugs sent down to libc++abi because people see this message in their
crash logs.

Differential Revision: https://reviews.llvm.org/D148630

Added: 
    

Modified: 
    libcxxabi/src/cxa_guard_impl.h

Removed: 
    


################################################################################
diff  --git a/libcxxabi/src/cxa_guard_impl.h b/libcxxabi/src/cxa_guard_impl.h
index 47fe2b20bd964..e00d54b3a7318 100644
--- a/libcxxabi/src/cxa_guard_impl.h
+++ b/libcxxabi/src/cxa_guard_impl.h
@@ -255,7 +255,7 @@ struct InitByteNoThreads {
     if (*init_byte_address == COMPLETE_BIT)
       return true;
     if (*init_byte_address & PENDING_BIT)
-      ABORT_WITH_MESSAGE("__cxa_guard_acquire detected recursive initialization");
+      ABORT_WITH_MESSAGE("__cxa_guard_acquire detected recursive initialization: do you have a function-local static variable whose initialization depends on that function?");
     *init_byte_address = PENDING_BIT;
     return false;
   }
@@ -325,7 +325,7 @@ struct InitByteGlobalMutex {
     // Check for possible recursive initialization.
     if (has_thread_id_support && (*init_byte_address & PENDING_BIT)) {
       if (*thread_id_address == current_thread_id.get())
-        ABORT_WITH_MESSAGE("__cxa_guard_acquire detected recursive initialization");
+        ABORT_WITH_MESSAGE("__cxa_guard_acquire detected recursive initialization: do you have a function-local static variable whose initialization depends on that function?");
     }
 
     // Wait until the pending bit is not set.
@@ -460,7 +460,7 @@ struct InitByteFutex {
 
         // Check for recursive initialization
         if (has_thread_id_support && thread_id.load(std::_AO_Relaxed) == current_thread_id.get()) {
-          ABORT_WITH_MESSAGE("__cxa_guard_acquire detected recursive initialization");
+          ABORT_WITH_MESSAGE("__cxa_guard_acquire detected recursive initialization: do you have a function-local static variable whose initialization depends on that function?");
         }
 
         if ((last_val & WAITING_BIT) == 0) {


        


More information about the libcxx-commits mailing list