1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

ntdll: Only allocate debug info in critical sections with RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO.

This commit is contained in:
Paul Gofman 2024-03-07 16:52:30 -06:00 committed by Alexandre Julliard
parent 9115dc0aba
commit 8b3944e134
3 changed files with 11 additions and 7 deletions

View file

@ -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);

View file

@ -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;
}

View file

@ -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);