@@ -228,20 +228,28 @@ template void EnterCritical(const char*, const char*, int, boost::mutex*, bool);
228228
229229void CheckLastCritical (void * cs, std::string& lockname, const char * guardname, const char * file, int line)
230230{
231- {
232- LockData& lockdata = GetLockData ();
233- std::lock_guard<std::mutex> lock (lockdata.dd_mutex );
234-
235- const LockStack& lock_stack = lockdata.m_lock_stacks [std::this_thread::get_id ()];
236- if (!lock_stack.empty ()) {
237- const auto & lastlock = lock_stack.back ();
238- if (lastlock.first == cs) {
239- lockname = lastlock.second .Name ();
240- return ;
241- }
231+ LockData& lockdata = GetLockData ();
232+ std::lock_guard<std::mutex> lock (lockdata.dd_mutex );
233+
234+ const LockStack& lock_stack = lockdata.m_lock_stacks [std::this_thread::get_id ()];
235+ if (!lock_stack.empty ()) {
236+ const auto & lastlock = lock_stack.back ();
237+ if (lastlock.first == cs) {
238+ lockname = lastlock.second .Name ();
239+ return ;
242240 }
243241 }
244- throw std::system_error (EPERM, std::generic_category (), strprintf (" %s:%s %s was not most recent critical section locked" , file, line, guardname));
242+
243+ LogPrintf (" INCONSISTENT LOCK ORDER DETECTED\n " );
244+ LogPrintf (" Current lock order (least recent first) is:\n " );
245+ for (const LockStackItem& i : lock_stack) {
246+ LogPrintf (" %s\n " , i.second .ToString ());
247+ }
248+ if (g_debug_lockorder_abort) {
249+ tfm::format (std::cerr, " %s:%s %s was not most recent critical section locked, details in debug log.\n " , file, line, guardname);
250+ abort ();
251+ }
252+ throw std::logic_error (strprintf (" %s was not most recent critical section locked" , guardname));
245253}
246254
247255void LeaveCritical ()
0 commit comments