https://bugs.winehq.org/show_bug.cgi?id=54560
Bug ID: 54560 Summary: mscoree:mscoree - test_loadpaths_execute() sometimes gets directory creation errors Product: Wine Version: unspecified Hardware: x86-64 OS: Windows Status: NEW Severity: normal Priority: P2 Component: mscoree Assignee: wine-bugs@winehq.org Reporter: fgouget@codeweavers.com
mscoree:mscoree - test_loadpaths_execute() sometimes gets directory creation errors. With only 3 instances in the past 8 months this is pretty rare:
* 2022-07-26 on w10pro64-ko (64-bit)
mscoree.c:614: Test failed: CreateDirectoryW(L"C:\Users\winetest\AppData\Local\Temp\loaC31F.tmp") failed: 183
* 2022-11-23 on w7u (32-bit)
mscoree.c:614: Test failed: CreateDirectoryW(L"C:\Users\winetest\AppData\Local\Temp\loaAB6B.tmp") failed: 183 mscoree.c:619: Test failed: CopyFileW(L"C:\Users\winetest\AppData\Local\Temp\loaAB6B.tmp\loadpaths.exe") failed: 3 mscoree.c:635: Test failed: CreateDirectoryW(L"C:\Users\winetest\AppData\Local\Temp\loaAB6B.tmp\libloadpaths") failed: 3 mscoree.c:643: Test failed: CopyFileW(L"C:\Users\winetest\AppData\Local\Temp\loaAB6B.tmp\libloadpaths\libloadpaths.dll") failed: 3 mscoree.c:647: Test failed: CreateProcessW(L"C:\Users\winetest\AppData\Local\Temp\loaAB6B.tmp\loadpaths.exe") failed: 3 mscoree.c:653: Test failed: L"libloadpaths\libloadpaths.dll": WaitForSingleObject returned -1: 6 mscoree.c:662: Test failed: L"libloadpaths\libloadpaths.dll": Failed to execute process mscoree.c:673: Test failed: DeleteFileW(L"C:\Users\winetest\AppData\Local\Temp\loaAB6B.tmp\libloadpaths\libloadpaths.dll") failed: 3 mscoree.c:675: Test failed: DeleteFileW(L"C:\Users\winetest\AppData\Local\Temp\loaAB6B.tmp\loadpaths.exe") failed: 3 mscoree.c:682: Test failed: RemoveDirectoryW(L"C:\Users\winetest\AppData\Local\Temp\loaAB6B.tmp\libloadpaths") failed: 3 mscoree.c:682: Test failed: RemoveDirectoryW(L"C:\Users\winetest\AppData\Local\Temp\loaAB6B.tmp") failed: 267
* 2023-02-21 on w10pro64-en-AE (64-bit)
mscoree.c:614: Test failed: CreateDirectoryW(L"C:\Users\winetest\AppData\Local\Temp\loaD02D.tmp") failed: 183 mscoree.c:635: Test failed: CreateDirectoryW(L"C:\Users\winetest\AppData\Local\Temp\loaD02D.tmp\private") failed: 183
See https://test.winehq.org/data/patterns.html#mscoree:mscoree
Where 3 == ERROR_PATH_NOT_FOUND 6 == ERROR_INVALID_HANDLE 183 == ERROR_ALREADY_EXISTS 267 == ERROR_DIRECTORY
https://bugs.winehq.org/show_bug.cgi?id=54560
François Gouget fgouget@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |source, testcase CC| |rbernon@codeweavers.com
https://bugs.winehq.org/show_bug.cgi?id=54560
--- Comment #1 from François Gouget fgouget@codeweavers.com --- AllocateLocallyUniqueId() seems to be going through the LowPart field of the unique id pretty fast. In one run on w1pro64 it went from d9e8e to 10f64b. Given that GetTempFileNameW() only uses the low 16 bits of maybe we can sometimes get collisions during the test?
That still does not entirely explain this issue since test_loadpaths_execute() normally deletes the temporary directories. As far as I can tell there is only one loophole compatible with the traces which is in when a timeout occurs a call where expect_fail is true. But that seems like a pretty big coincidence.
https://bugs.winehq.org/show_bug.cgi?id=54560
--- Comment #2 from François Gouget fgouget@codeweavers.com --- I can sort of reproduce this if I make id.LowPart constant and make sure to time out in the expect_failure cases:
mscoree.c:616: Test failed: CreateDirectoryW(L"C:\users\fgouget\Temp\loa4216.tmp") failed: 183 mscoree.c:637: Test failed: CreateDirectoryW(L"C:\users\fgouget\Temp\loa4216.tmp\private") failed: 183
But that scenario still feels pretty unlikely.
https://bugs.winehq.org/show_bug.cgi?id=54560
--- Comment #3 from Esme Povirk madewokherd@gmail.com --- If CreateDirectoryW fails with ERROR_DIRECTORY_EXISTS, we should probably increment the id and retry.
I'm not sure why AllocateLocallyUniqueId is used at all, it doesn't seem to be designed for this.
https://bugs.winehq.org/show_bug.cgi?id=54560
François Gouget fgouget@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |c11e923422f40ab0ee5e512d81c | |b14c85faff6a5 Status|NEW |RESOLVED Resolution|--- |FIXED
--- Comment #4 from François Gouget fgouget@codeweavers.com --- The commit below should fix this issue. However as it is quite rare it will take time to be sure.
commit c11e923422f40ab0ee5e512d81cb14c85faff6a5 Author: François Gouget fgouget@codeweavers.com Date: Sun Mar 19 20:07:33 2023 +0100
mscoree/tests: Avoid temporary directory name collisions.
test_loadpaths_execute() was sometimes getting ERROR_ALREADY_EXISTS when creating its temporary directoryi. That was probably because GetTempFileNameW() only uses the low 16-bits of the 'random' LUID which goes over a wider range, potentially leading to collisions in the lower 16-bits. Avoid AllocateLocallyUniqueId() entirely and add a helper function to create a guaranteed new directory. Also try to use the current directory first as it is assumed to have been configured to ward off anti-virus programs (specifically Microsoft Defender) which is especially important when writing executables to that location. Only switch to the system's temporary directory if the current directory is not a writable location.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54560
https://bugs.winehq.org/show_bug.cgi?id=54560
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #5 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 8.5.