Module: wine Branch: master Commit: 8b3944e1341baaf693927c8b758851d2dbba725a URL: https://gitlab.winehq.org/wine/wine/-/commit/8b3944e1341baaf693927c8b758851d...
Author: Paul Gofman pgofman@codeweavers.com Date: Thu Mar 7 16:52:30 2024 -0600
ntdll: Only allocate debug info in critical sections with RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO.
---
dlls/kernel32/tests/sync.c | 8 ++++---- dlls/ntdll/sync.c | 8 ++++++-- dlls/ntdll/tests/rtl.c | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c index 25cf75cd686..c06ced47298 100644 --- a/dlls/kernel32/tests/sync.c +++ b/dlls/kernel32/tests/sync.c @@ -2741,7 +2741,7 @@ static void test_crit_section(void) to override that. */ memset(&cs, 0, sizeof(cs)); InitializeCriticalSection(&cs); - todo_wine ok(cs.DebugInfo == (void *)(ULONG_PTR)-1 || broken(!!cs.DebugInfo) /* before Win8 */, + ok(cs.DebugInfo == (void *)(ULONG_PTR)-1 || broken(!!cs.DebugInfo) /* before Win8 */, "Unexpected debug info pointer %p.\n", cs.DebugInfo); DeleteCriticalSection(&cs); ok(cs.DebugInfo == NULL, "Unexpected debug info pointer %p.\n", cs.DebugInfo); @@ -2755,7 +2755,7 @@ static void test_crit_section(void) memset(&cs, 0, sizeof(cs)); ret = pInitializeCriticalSectionEx(&cs, 0, 0); ok(ret, "Failed to initialize critical section.\n"); - todo_wine ok(cs.DebugInfo == (void *)(ULONG_PTR)-1 || broken(!!cs.DebugInfo) /* before Win8 */, + ok(cs.DebugInfo == (void *)(ULONG_PTR)-1 || broken(!!cs.DebugInfo) /* before Win8 */, "Unexpected debug info pointer %p.\n", cs.DebugInfo); DeleteCriticalSection(&cs); ok(cs.DebugInfo == NULL, "Unexpected debug info pointer %p.\n", cs.DebugInfo); @@ -2765,12 +2765,12 @@ static void test_crit_section(void) ok(ret, "Failed to initialize critical section.\n"); ok(cs.DebugInfo == (void *)(ULONG_PTR)-1, "Unexpected debug info pointer %p.\n", cs.DebugInfo); DeleteCriticalSection(&cs); - todo_wine ok(cs.DebugInfo == NULL, "Unexpected debug info pointer %p.\n", cs.DebugInfo); + ok(cs.DebugInfo == NULL, "Unexpected debug info pointer %p.\n", cs.DebugInfo);
memset(&cs, 0, sizeof(cs)); ret = pInitializeCriticalSectionEx(&cs, 0, 0); ok(ret, "Failed to initialize critical section.\n"); - todo_wine ok(cs.DebugInfo == (void *)(ULONG_PTR)-1 || broken(!!cs.DebugInfo) /* before Win8 */, + ok(cs.DebugInfo == (void *)(ULONG_PTR)-1 || broken(!!cs.DebugInfo) /* before Win8 */, "Unexpected debug info pointer %p.\n", cs.DebugInfo); DeleteCriticalSection(&cs); ok(cs.DebugInfo == NULL, "Unexpected debug info pointer %p.\n", cs.DebugInfo); diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c index bb5dcbb66e6..00ab614803f 100644 --- a/dlls/ntdll/sync.c +++ b/dlls/ntdll/sync.c @@ -232,7 +232,7 @@ NTSTATUS WINAPI RtlInitializeCriticalSectionEx( RTL_CRITICAL_SECTION *crit, ULON * is done, then debug info should be managed through Rtlp[Allocate|Free]DebugInfo * so (e.g.) MakeCriticalSectionGlobal() doesn't free it using HeapFree(). */ - if (flags & RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO) + if (!(flags & RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO)) crit->DebugInfo = no_debug_info_marker; else { @@ -288,7 +288,11 @@ NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit ) crit->DebugInfo = NULL; } } - else NtClose( crit->LockSemaphore ); + else + { + NtClose( crit->LockSemaphore ); + crit->DebugInfo = NULL; + } crit->LockSemaphore = 0; return STATUS_SUCCESS; } diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c index 4a4370d5903..224eeec6df7 100644 --- a/dlls/ntdll/tests/rtl.c +++ b/dlls/ntdll/tests/rtl.c @@ -2973,7 +2973,7 @@ static void test_RtlInitializeCriticalSectionEx(void)
memset(&cs, 0x11, sizeof(cs)); pRtlInitializeCriticalSectionEx(&cs, 0, 0); - ok((cs.DebugInfo != NULL && cs.DebugInfo != no_debug) || broken(cs.DebugInfo == no_debug) /* >= Win 8 */, + ok(cs.DebugInfo == no_debug || broken(cs.DebugInfo != NULL && cs.DebugInfo != no_debug) /* < Win8 */, "expected DebugInfo != NULL and DebugInfo != ~0, got %p\n", cs.DebugInfo); ok(cs.LockCount == -1, "expected LockCount == -1, got %ld\n", cs.LockCount); ok(cs.RecursionCount == 0, "expected RecursionCount == 0, got %ld\n", cs.RecursionCount);