https://bugs.winehq.org/show_bug.cgi?id=52892
Bug ID: 52892 Summary: The 64-bit ntdll:thread fails on w7pro64 and w864 Product: Wine Version: unspecified Hardware: x86-64 OS: Windows Status: NEW Severity: normal Priority: P2 Component: ntdll Assignee: wine-bugs@winehq.org Reporter: fgouget@codeweavers.com
The 64-bit ntdll:thread fails on w7pro64 and w864:
thread.c:153: Test failed: Multiple threads have TEB 000007FFFFFDC000.
https://test.winehq.org/data/patterns.html#ntdll:thread
The failure is hard to reproduce but the test was introduced by this commit:
commit 6d4ec1255acceec7152ed98764ee29991ac04f10 Author: Brendan Shanks bshanks@codeweavers.com AuthorDate: Mon Apr 18 11:25:10 2022 -0700 Commit: Alexandre Julliard julliard@winehq.org CommitDate: Mon Apr 18 21:48:15 2022 +0200
ntdll/tests: Test that threads have unique TEBs.
Signed-off-by: Brendan Shanks bshanks@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
Specifically the issue is with the line below:
+ ok( teb1 != teb2, "Multiple threads have TEB %p.\n", teb1 );
I think the issue is that there is no guarantee that the two test threads are running at the same time. I suspect that sometimes what happens is this [1]:
* status = pNtCreateThreadEx( &threads[0], ... &teb1, ... ); A new TEB is allocated, the first thread starts, sets teb1 and terminates at which time its TEB is freed.
* status = pNtCreateThreadEx( &threads[1], ... &teb2, ... ); A new TEB is allocated, hey there's a fresh TEB that has just bee freed! [2]. The second thread starts and sets teb2.
* WaitForMultipleObjects( 2, threads, TRUE, INFINITE ); Wait for both threads.
* ok( teb1 != teb2, "Multiple threads have TEB %p.\n", teb1 ); Hey, both threads used the same TEB! But did they do so at the same time?
One hacky fix would be to at a small sleep in the test threads but that's introducing race conditions. A better fix would be for the main thread to tell the test threads when they can exit through some synchronization object.
[1] This may be tied to how the scheduler behaves which may limit the issue to specific Windows versions. [2] And that's probably tied to how the memory allocator behaves: more memory locality or less chance of overwriting (incorrectly) still in use memory. Again this could limit the issue to some Windows versions.
https://bugs.winehq.org/show_bug.cgi?id=52892
François Gouget fgouget@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |regression, source, | |testcase Regression SHA1| |6d4ec1255acceec7152ed98764e | |e29991ac04f10
https://bugs.winehq.org/show_bug.cgi?id=52892
François Gouget fgouget@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |bshanks@codeweavers.com
https://bugs.winehq.org/show_bug.cgi?id=52892
--- Comment #1 from Brendan Shanks bshanks@codeweavers.com --- Ah thanks, this should be fixed by 95024c31551c35607ce9669b1e22bd9136edf3da
https://bugs.winehq.org/show_bug.cgi?id=52892
François Gouget fgouget@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |95024c31551c35607ce9669b1e2 | |2bd9136edf3da Status|NEW |RESOLVED Resolution|--- |FIXED
--- Comment #2 from François Gouget fgouget@codeweavers.com --- Yep. It's not happening anymore. Closing. Thanks for the patch.
https://bugs.winehq.org/show_bug.cgi?id=52892
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #3 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 7.9.