https://bugs.winehq.org/show_bug.cgi?id=51821
Bug ID: 51821 Summary: EVE Online Sisi Client Crashes Due to differences in how Wine and Windows handle LoadLibraryExW Undefined Behavior Product: Wine Version: 6.16 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: algebro@tuta.io Distribution: ---
I've been chasing this for the last few days and think I may finally have enough information to finally open a bug report. As of a few days ago, the Sisi testing client for EVE stopped working in recent versions of Wine, and the logs showed an unhandled Python error in a module called launchdarkly_client.pyd:
```ImportError: Failed to load DLL: Success```
I chased this down in a debugger and noticed they're passing a relative path to LoadLibraryExW for this library only (full/absolute paths for every other module), and 8 for dwFlags:
```hLibModule = LoadLibraryExW((LPCWSTR)plVar4[3],(HANDLE)0x0,8)```
Per the Microsoft documentation, 8 for dwFlags is undefined when the first argument is a relative path: https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloader...
Weirdly enough, the library loads fine on Windows (I've confirmed in windbg), but it fails with error code 0x7e (Module not found) when trying to load it in wine. Other users running Wine 4.4 say Sisi launches fine and doesn't run into the error, although I havent been able to get older versions to build to try and test it, but it sounds like there is a difference between how recent Wine versions implement LoadLibraryExW() and how Windows does, at least with regards to the undefined behavior.
Let me know if I can provide any other information that would be helpful for tracking this down.
Thanks!
https://bugs.winehq.org/show_bug.cgi?id=51821
--- Comment #1 from algebro@tuta.io --- Created attachment 70705 --> https://bugs.winehq.org/attachment.cgi?id=70705 LoadLibraryTest
This POC reproduces the behavior accurately I believe. It attempts to load the library with a relative path and dwFlags 8. On Windows, it loads successfully if ran from a parent directory:
bin64\LoadLibraryTest.exe Full path name: C:\EVE\SharedCache\sisi\launchdarkly_client.pyd Attempting to load launchdarkly_client.pyd Module loaded successfully
On Linux with Wine 6.16, it fails:
wine ./bin64/LoadLibraryTest.exe Full path name: C:\EVE\SharedCache\sisi\launchdarkly_client.pyd Attempting to load launchdarkly_client.pyd Module failed to load
I can't share the actual module due to copyright/drm issues, but you should be able to test it with any shared library I imagine.
https://bugs.winehq.org/show_bug.cgi?id=51821
--- Comment #2 from algebro@tuta.io --- Forgot to add that Wine DOES load the module successfully when being ran from the same directory, so it's not an issue with Wine just refusing to load it:
SharedCache  sisi  bin64  wine ./LoadLibraryTest.exe Full path name: C:\EVE\SharedCache\sisi\bin64\launchdarkly_client.pyd Attempting to load launchdarkly_client.pyd Module loaded successfully
https://bugs.winehq.org/show_bug.cgi?id=51821
Anton Vorobyov phoenix@mail.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |phoenix@mail.ru
--- Comment #3 from Anton Vorobyov phoenix@mail.ru --- I am affected by this issue as well
https://bugs.winehq.org/show_bug.cgi?id=51821
algebro@tuta.io changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |loader
https://bugs.winehq.org/show_bug.cgi?id=51821
yuratsts yura.tsts@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |yura.tsts@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=51821
ConcernedCapsuleer cuchumino@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |cuchumino@gmail.com
--- Comment #4 from ConcernedCapsuleer cuchumino@gmail.com --- Similarly am having this issue as well when loading SiSi for this launcher.
https://bugs.winehq.org/show_bug.cgi?id=51821
algebro@tuta.io changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|loader |-unknown
https://bugs.winehq.org/show_bug.cgi?id=51821
--- Comment #5 from algebro@tuta.io --- I've been digging through the loader.c source and am still trying to understand what the problem is. In a debugging session, I was able to verify that LdrGetDllPath() within load_library() does not return the executable directory in the path for this module, but it does with all the others:
``` Stopped on breakpoint 1 at 0x000000007b027ee8 Wine-dbg>x/u $rcx C:\EVE\SharedCache\sisi\bin64;C:\windows\system32;C:\windows\system;C:\windows;.;C:\windows\system32;C:\windows;C:\windows\system32\wbem;C:\w indows\system32\WindowsPowershell\v1.0 Wine-dbg>x/x $r8 + 8 077c6440 Wine-dbg>x/u 0x077c6440 C:\EVE\SharedCache\sisi\bin64\factionsLoader.pyd
[...]
``` Stopped on breakpoint 1 at 0x000000007b027ee8 Wine-dbg>x/x $r8 + 8 1584b780 Wine-dbg>x/u 0x1584b780 launchdarkly_client.pyd Wine-dbg>x/u $rcx C:\windows\system32;C:\windows\system;C:\windows;.;C:\windows\system32;C:\windows;C:\windows\system32\wbem;C:\windows\system32\WindowsPowersh ell\v1.0 ```
I guess the problem is somewhere in LdrGetDllPath() or get_dll_load_path(), but I don't see any comments that look like they would've directly broken something that was working before...
https://bugs.winehq.org/show_bug.cgi?id=51821
--- Comment #6 from algebro@tuta.io --- I've confirmed that by moving `launchdarkly_client.pyd` one directory up into the parent (from C:\EVE\SharedCache\sisi\bin64 to C:\EVE\SharedCache\sisi), the game launches perfectly, which should confirm it's an issue with the search path in Wine. Still digging into things but if the wine devs have any input I'd be glad to hear it :)
Thanks for tolerating all of my rubber ducking!
https://bugs.winehq.org/show_bug.cgi?id=51821
algebro@tuta.io changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |ntdll
https://bugs.winehq.org/show_bug.cgi?id=51821
--- Comment #7 from algebro@tuta.io --- Per @gofman's suggestion, I added a test in dlls/kernel32/tests/path.c that simply calls LdrGetDllPath() with LOAD_WITH_ALTERED_SEARCH_PATH and prints the value:
ret = pLdrGetDllPath( buffer, LOAD_WITH_ALTERED_SEARCH_PATH, &path, &unknown_ptr ); ok( ret != 0, "algebro Test: Path: %s\n", wine_dbgstr_w(path));
When running on Windows, the current directory is added to the PATH:
Path: L"C:\Users\algebro\Documents;C:\WINDOWS\SYSTEM32;C:\WINDOWS\system;C:\WINDOWS;."
When running on Wine, it is not added:
Path: L"C:\windows\system32;C:\windows\system;C:\windows;."
So this appears to be a bug specifically in LdrGetDllPath() with LOAD_WITH_ALTERED_SEARCH_PATH, where wine doesn't behave like windows.
https://bugs.winehq.org/show_bug.cgi?id=51821
winetest@luukku.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |winetest@luukku.com
--- Comment #8 from winetest@luukku.com --- duplicate or at least related to bug 26350.
https://bugs.winehq.org/show_bug.cgi?id=51821
--- Comment #9 from algebro@tuta.io --- Created attachment 70739 --> https://bugs.winehq.org/attachment.cgi?id=70739 Patch to append the exe directory when loading DLLs with 0x8
Attaching a patch here for EVE players to test with Sisi. Working on conformance tests to try and figure out if removing this condition is the correct approach, or if finer checks are needed. Currently there are no conformance tests for LOAD_WITH_ALTERED_SEARCH_PATH.
https://bugs.winehq.org/show_bug.cgi?id=51821
algebro@tuta.io changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|EVE Online Sisi Client |EVE Online Client Crashes |Crashes Due to differences |Due to differences in how |in how Wine and Windows |Wine and Windows handle |handle LoadLibraryExW |LoadLibraryExW Undefined |Undefined Behavior |Behavior
https://bugs.winehq.org/show_bug.cgi?id=51821
--- Comment #10 from algebro@tuta.io --- I updated the title because this change has now been rolled into the release client as well (tranquility). https://source.winehq.org/patches/data/216868 is confirmed to fix both clients.
https://bugs.winehq.org/show_bug.cgi?id=51821
algebro@tuta.io changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|6.16 |6.19
https://bugs.winehq.org/show_bug.cgi?id=51821
ppfeufer info@ppfeufer.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |info@ppfeufer.de
https://bugs.winehq.org/show_bug.cgi?id=51821
algebro@tuta.io changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|EVE Online Client Crashes |EVE Online Client Crashes |Due to differences in how |Due to differences in how |Wine and Windows handle |Wine and Windows handle |LoadLibraryExW Undefined |LdrGetDllPath with dwFlags |Behavior |0x8 and relative path
https://bugs.winehq.org/show_bug.cgi?id=51821
--- Comment #11 from yuratsts yura.tsts@gmail.com --- proposed patch works for me (gentoo, wine-staging-6.19)
https://bugs.winehq.org/show_bug.cgi?id=51821
willy wilroz@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |wilroz@gmail.com
--- Comment #12 from willy wilroz@gmail.com --- Release client now crashes on launch for me too.
https://bugs.winehq.org/show_bug.cgi?id=51821
N. Andrew Walsh n.andrew.walsh@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |n.andrew.walsh@gmail.com
--- Comment #13 from N. Andrew Walsh n.andrew.walsh@gmail.com --- this issue affects me. How do I apply the patch?
https://bugs.winehq.org/show_bug.cgi?id=51821
--- Comment #14 from Austin English austinenglish@gmail.com --- (In reply to N. Andrew Walsh from comment #13)
this issue affects me. How do I apply the patch?
See https://wiki.winehq.org/Patching / https://wiki.winehq.org/Building_Wine
https://bugs.winehq.org/show_bug.cgi?id=51821
greg2008200@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |greg2008200@gmail.com
--- Comment #15 from greg2008200@gmail.com --- The proposed patch worked for me.
https://bugs.winehq.org/show_bug.cgi?id=51821
heroeschman@gmx.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |heroeschman@gmx.de
--- Comment #16 from heroeschman@gmx.de --- The patch works for me too.
https://bugs.winehq.org/show_bug.cgi?id=51821
Kevin Andrews kjandrews0@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |kjandrews0@gmail.com
--- Comment #17 from Kevin Andrews kjandrews0@gmail.com --- Patch working for me on both wine and wine-staging across two machines.
https://bugs.winehq.org/show_bug.cgi?id=51821
g2g591@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |g2g591@gmail.com
--- Comment #18 from g2g591@gmail.com --- still have this issue with wine 6.21 (with staging patchset) , and the attached patch still fixes it.
https://bugs.winehq.org/show_bug.cgi?id=51821
nick@foxsec.net changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@foxsec.net
--- Comment #19 from nick@foxsec.net --- Created attachment 71084 --> https://bugs.winehq.org/attachment.cgi?id=71084 Upstream patch v5 - 1/2
https://bugs.winehq.org/show_bug.cgi?id=51821
--- Comment #20 from nick@foxsec.net --- Created attachment 71085 --> https://bugs.winehq.org/attachment.cgi?id=71085 Upstream patch v5 - 2/2
I've attached the patches I've been trying to get upstreamed for a bit, but it's been slow-going because there aren't a lot of maintainers who are comfortable with this area of the codebase. @zf, @gofman etc., would you guys consider adding this to wine-staging for now? I'm planning to continue trying to get these upstreamed but I'm not sure it's going to be able to happen before the upcoming code freeze.
Please let me know if there's anything I can do to help. Thanks!
https://bugs.winehq.org/show_bug.cgi?id=51821
nick@foxsec.net changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |gofmanp@gmail.com, | |z.figura12@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=51821
--- Comment #21 from algebro@tuta.io --- The patches to fix this have been merged upstream in https://source.winehq.org/git/wine.git/commit/ef26f7bd5cf36806f7b465dc1942ab...
https://bugs.winehq.org/show_bug.cgi?id=51821
algebro@tuta.io changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|UNCONFIRMED |RESOLVED
--- Comment #22 from algebro@tuta.io --- Fixed by ef26f7bd5cf36806f7b465dc1942ab6a2e0541b9
https://bugs.winehq.org/show_bug.cgi?id=51821
algebro@tuta.io changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |ef26f7bd5cf36806f7b465dc194 | |2ab6a2e0541b9
https://bugs.winehq.org/show_bug.cgi?id=51821
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #23 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 7.0-rc1.
https://bugs.winehq.org/show_bug.cgi?id=51821
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |6.0.x
https://bugs.winehq.org/show_bug.cgi?id=51821
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|6.0.x |---
--- Comment #24 from Michael Stefaniuc mstefani@winehq.org --- Removing the 6.0.x milestone from bug fixes included in 6.0.4.