https://bugs.winehq.org/show_bug.cgi?id=52995
Bug ID: 52995 Summary: shell32:shelllink crashes in Wine cause shell32:shellpath's test_PathResolve() to fail (test.bat file) Product: Wine Version: unspecified Hardware: x86-64 OS: Linux Status: NEW Severity: normal Priority: P2 Component: shell32 Assignee: wine-bugs@winehq.org Reporter: fgouget@codeweavers.com Distribution: ---
shell32:shellpath's test_PathResolve() fails seemingly randomly:
shellpath.c:3049: Test failed: test 4: expected L"C:\users\winetest\Temp\test.lnk", got L"C:\users\winetest\Temp\test.bat" shellpath.c:3049: Test failed: test 8: expected L"C:\users\winetest\Temp\test.lnk", got L"C:\users\winetest\Temp\test.bat" shellpath.c:3048: Test failed: test 14: expected 0, got 1 shellpath.c:3049: Test failed: test 14: expected L"C:\users\winetest\Temp\test", got L"C:\users\winetest\Temp\test.bat" shellpath.c:3049: Test failed: test 16: expected L"C:\users\winetest\Temp\test.lnk", got L"C:\users\winetest\Temp\test.bat" shellpath.c:3049: Test failed: test 19: expected L"C:\users\winetest\Temp\test.lnk", got L"C:\users\winetest\Temp\test.bat" shellpath.c:3049: Test failed: test 20: expected L"C:\users\winetest\Temp\test.lnk", got L"C:\users\winetest\Temp\test.bat" shellpath.c:3049: Test failed: test 24: expected L"C:\users\winetest\Temp\test.lnk", got L"C:\users\winetest\Temp\test.bat" shellpath.c:3048: Test failed: test 26: expected 0, got 1 shellpath.c:3049: Test failed: test 26: expected L"C:\users\winetest\Temp\test", got L"C:\users\winetest\Temp\test.bat"
https://test.winehq.org/data/patterns.html#shell32:shellpath
But it turns out the dates when shell32:shellpath failures all match dates when shell32:shelllink crashed:
https://test.winehq.org/data/patterns.html#shell32:shelllink
What happens is that shell32:shellpath looks for a "test.lnk" file. But if one creates a "c:\users...\Temp\test.bat" file before starting the test, that's what gets returned instead, thus causing the failures. shell32:shelllink just happens to use a file by that name. Normally it gets cleaned up but that just does not happen when shell32:shelllink crashes!
So I think the right fix would be to make shell32:shellpath more resilient: * Delete "test.*" before checking for test.lnk. But that runs the risk of deleting files dear to the person running the test (they are in a Temp directory but still). * Use some GetTempFileName() or some similar API to generate a unique filename. * Or just use a name that's less likely to be a leftover from a previous test, "shellpath.lnk" for instance. Very basic but maybe sufficient.