recent vs2022 upgrade bypasses _Mtx_init* calls
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msvcp140/tests/msvcp140.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcp140/tests/msvcp140.c b/dlls/msvcp140/tests/msvcp140.c index d2bcd192f45..7b6dfa1af3b 100644 --- a/dlls/msvcp140/tests/msvcp140.c +++ b/dlls/msvcp140/tests/msvcp140.c @@ -166,11 +166,15 @@ typedef struct void *tail; } critical_section;
-typedef struct -{ +typedef union { + critical_section conc; + SRWLOCK win; +} cs; + +typedef struct { DWORD flags; - critical_section cs; ULONG_PTR unknown; + cs cs; DWORD thread_id; DWORD count; } *_Mtx_t; @@ -1682,15 +1686,21 @@ static void test__Mtx(void)
ok(mtx->thread_id == -1, "mtx.thread_id = %lx\n", mtx->thread_id); ok(mtx->count == 0, "mtx.count = %lx\n", mtx->count); + todo_wine + ok(mtx->cs.win.Ptr == 0, "mtx.cs == %p\n", mtx->cs.win.Ptr); p__Mtx_lock(mtx); ok(mtx->thread_id == GetCurrentThreadId(), "mtx.thread_id = %lx\n", mtx->thread_id); ok(mtx->count == 1, "mtx.count = %lx\n", mtx->count); + ok(mtx->cs.win.Ptr != 0, "mtx.cs == %p\n", mtx->cs.win.Ptr); p__Mtx_lock(mtx); ok(mtx->thread_id == GetCurrentThreadId(), "mtx.thread_id = %lx\n", mtx->thread_id); ok(mtx->count == 1, "mtx.count = %lx\n", mtx->count); + ok(mtx->cs.win.Ptr != 0, "mtx.cs == %p\n", mtx->cs.win.Ptr); p__Mtx_unlock(mtx); ok(mtx->thread_id == -1, "mtx.thread_id = %lx\n", mtx->thread_id); ok(mtx->count == 0, "mtx.count = %lx\n", mtx->count); + todo_wine + ok(mtx->cs.win.Ptr == 0, "mtx.cs == %p\n", mtx->cs.win.Ptr); p__Mtx_unlock(mtx); ok(mtx->thread_id == -1, "mtx.thread_id = %lx\n", mtx->thread_id); ok(mtx->count == -1, "mtx.count = %lx\n", mtx->count);
From: Daniel Lehman dlehman25@gmail.com
--- dlls/msvcp140/tests/msvcp140.c | 2 -- dlls/msvcp90/misc.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/dlls/msvcp140/tests/msvcp140.c b/dlls/msvcp140/tests/msvcp140.c index 7b6dfa1af3b..0688239a1fc 100644 --- a/dlls/msvcp140/tests/msvcp140.c +++ b/dlls/msvcp140/tests/msvcp140.c @@ -1686,7 +1686,6 @@ static void test__Mtx(void)
ok(mtx->thread_id == -1, "mtx.thread_id = %lx\n", mtx->thread_id); ok(mtx->count == 0, "mtx.count = %lx\n", mtx->count); - todo_wine ok(mtx->cs.win.Ptr == 0, "mtx.cs == %p\n", mtx->cs.win.Ptr); p__Mtx_lock(mtx); ok(mtx->thread_id == GetCurrentThreadId(), "mtx.thread_id = %lx\n", mtx->thread_id); @@ -1699,7 +1698,6 @@ static void test__Mtx(void) p__Mtx_unlock(mtx); ok(mtx->thread_id == -1, "mtx.thread_id = %lx\n", mtx->thread_id); ok(mtx->count == 0, "mtx.count = %lx\n", mtx->count); - todo_wine ok(mtx->cs.win.Ptr == 0, "mtx.cs == %p\n", mtx->cs.win.Ptr); p__Mtx_unlock(mtx); ok(mtx->thread_id == -1, "mtx.thread_id = %lx\n", mtx->thread_id); diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c index a1c9c7f0646..ad89aca6728 100644 --- a/dlls/msvcp90/misc.c +++ b/dlls/msvcp90/misc.c @@ -715,10 +715,10 @@ unsigned int __cdecl _Random_device(void) typedef struct { DWORD flags; - cs cs; #if _MSVCP_VER >= 140 ULONG_PTR unknown; #endif + cs cs; DWORD thread_id; DWORD count; } *_Mtx_t;
Piotr Caban (@piotr) commented about dlls/msvcp140/tests/msvcp140.c:
void *tail;
} critical_section;
-typedef struct -{ +typedef union {
- critical_section conc;
- SRWLOCK win;
+} cs;
+typedef struct { DWORD flags;
- critical_section cs; ULONG_PTR unknown;
Please initialize `unknown` in `_Mtx_init_in_situ`. Otherwise the tests may randomly fail accessing uninitialized value.