Module: wine Branch: master Commit: e2c081a8ebc0722df08e85e32fc26bd42c23ae46 URL: https://gitlab.winehq.org/wine/wine/-/commit/e2c081a8ebc0722df08e85e32fc26bd...
Author: Zebediah Figura zfigura@codeweavers.com Date: Fri Nov 18 20:08:09 2022 -0600
ntdll: Trace the name of critical sections which are released while not acquired.
---
dlls/ntdll/sync.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c index f9f906df723..4f5ee820286 100644 --- a/dlls/ntdll/sync.c +++ b/dlls/ntdll/sync.c @@ -155,6 +155,13 @@ static BOOL crit_section_has_debuginfo( const RTL_CRITICAL_SECTION *crit ) return crit->DebugInfo != NULL && crit->DebugInfo != no_debug_info_marker; }
+static const char *crit_section_get_name( const RTL_CRITICAL_SECTION *crit ) +{ + if (crit_section_has_debuginfo( crit )) + return (char *)crit->DebugInfo->Spare[0]; + return "?"; +} + static inline HANDLE get_semaphore( RTL_CRITICAL_SECTION *crit ) { HANDLE ret = crit->LockSemaphore; @@ -311,9 +318,8 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit )
if ( status == STATUS_TIMEOUT ) { - const char *name = NULL; - if (crit_section_has_debuginfo( crit )) name = (char *)crit->DebugInfo->Spare[0]; - if (!name) name = "?"; + const char *name = crit_section_get_name( crit ); + ERR( "section %p %s wait timed out in thread %04lx, blocked by %04lx, retrying (60 sec)\n", crit, debugstr_a(name), GetCurrentThreadId(), HandleToULong(crit->OwningThread) ); status = wait_semaphore( crit, 60 ); @@ -461,7 +467,7 @@ NTSTATUS WINAPI RtlLeaveCriticalSection( RTL_CRITICAL_SECTION *crit ) if (--crit->RecursionCount) { if (crit->RecursionCount > 0) InterlockedDecrement( &crit->LockCount ); - else ERR( "section %p is not acquired\n", crit ); + else ERR( "section %p %s is not acquired\n", crit, debugstr_a( crit_section_get_name( crit ))); } else {