https://bugs.winehq.org/show_bug.cgi?id=45864
Bug ID: 45864 Summary: wine mono cannot load 64-bit DLLs Product: Wine Version: 3.0.2 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: mscoree Assignee: wine-bugs@winehq.org Reporter: paleozogt@gmail.com Distribution: ---
Created attachment 62358 --> https://bugs.winehq.org/attachment.cgi?id=62358 wine mono project and binaries
Attached is an example project that makes a PInvoke call to a custom native function. It produces HelloWorld.exe (from HelloWorld.cs) and HelloWorld.dll (from HelloworldNative.cpp).
If I build a 32-bit HelloWorld.dll, I am able to run HelloWorld.exe in Wine with a WINEPREFIX generated from both WINEARCH=wine32 and WINEARCH=wine64.
However, if I build a 64-bit HelloWorld.dll, I am unable to run HelloWorld.exe in Wine with a WINEPREFIX generated from either WINEARCH=wine32 or WINEARCH=wine64. I wouldn't expect WINEARCH=wine32 to work for a 64-bit DLL, but its surprising that WINEARCH=wine64 doesn't work. (With WINEARCH=wine64 I'm otherwise able to run 64-bit native executables without a problem.)
The failure looks like this:
HelloWorld.exe
002f:err:mscoree:LoadLibraryShim error reading registry key for installroot
Unhandled Exception: System.DllNotFoundException: HelloWorld at (wrapper managed-to-native) HelloWorld.Hello:helloWorld () at HelloWorld.Hello.Main () [0x00001] in <93c08d3d3d384696aa77bc80f6a731c1>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: HelloWorld at (wrapper managed-to-native) HelloWorld.Hello:helloWorld () at HelloWorld.Hello.Main () [0x00001] in <93c08d3d3d384696aa77bc80f6a731c1>:0
It seems like Wine Mono is either running as a 32-bit process or something is wrong with how Wine Mono's PInvoke DllImport searches for compatible DLLs.
https://bugs.winehq.org/show_bug.cgi?id=45864
Aaron Simmons paleozogt@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |paleozogt@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=45864
zzzzzyzz@hacari.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |zzzzzyzz@hacari.org
https://bugs.winehq.org/show_bug.cgi?id=45864
--- Comment #1 from Aaron Simmons paleozogt@gmail.com --- I added
Console.WriteLine("Environment.Is64BitProcess " + Environment.Is64BitProcess);
to HelloWorld.cs.
And now I see:
$ echo $WINEARCH win64 $ wine64 cmd Microsoft Windows 10.0.10240 (3.0.2)
HelloWorld.exe
002e:err:mscoree:LoadLibraryShim error reading registry key for installroot Environment.Is64BitProcess False
Unhandled Exception: System.DllNotFoundException: HelloWorld at (wrapper managed-to-native) HelloWorld.Hello:helloWorld () at HelloWorld.Hello.Main () [0x0001b] in <a9c299cdfe4f4d858cb60436a47e9150>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: HelloWorld at (wrapper managed-to-native) HelloWorld.Hello:helloWorld () at HelloWorld.Hello.Main () [0x0001b] in <a9c299cdfe4f4d858cb60436a47e9150>:0
It seems that, indeed, Wine Mono is running as a 32-bit process, even with a 64-bit WINEARCH. How can we make Wine Mono run in a 64-bit process?
https://bugs.winehq.org/show_bug.cgi?id=45864
--- Comment #2 from Aaron Simmons paleozogt@gmail.com --- Created attachment 62363 --> https://bugs.winehq.org/attachment.cgi?id=62363 wine mono project and binaries (part 2)
C# hello world project and binaries.
https://bugs.winehq.org/show_bug.cgi?id=45864
--- Comment #3 from Aaron Simmons paleozogt@gmail.com --- I've uploaded a new project that builds with -platform:x86 or -platform:x64. It also doesn't have a native DLL involved at all-- its a simple HelloWorld.cs.
The platform arg seems to be the culprit behind why Wine Mono was running in a 32-bit process. On a real Windows machine, a C# exe without this parameter will run as the arch of the operating system. I guess Wine Mono needs it to be explicit.
Unfortunately, now that its trying to run HelloWorld.exe in a 64-bit process, it crashes:
$ file HelloWorld.exe HelloWorld.exe: PE32+ executable (console) x86-64 Mono/.Net assembly, for MS Windows
$ mono HelloWorld.exe Environment.Is64BitProcess True Runtime Mono.Runtime
$ echo $WINEARCH win64
$ wine64 cmd Microsoft Windows 10.0.10240 (3.0.2)
Z:\winebug\helloworld64\bin>HelloWorld.exe wine: Unhandled page fault on read access to 0x140000000 at address 0x140000000 (thread 0030), starting debugger... Unhandled exception: page fault on read access to 0x140000000 in 64-bit code (0x0000000140000000). Register dump: rip:0000000140000000 rsp:000000000053fdd8 rbp:000000000053ffd0 eflags:00010246 ( R- -- I Z- -P- ) rax:0000000140000000 rbx:0000000000000000 rcx:00007fffffeaf000 rdx:0000000000000000 rsi:0000000000000000 rdi:000000000053fe40 r8:000000000053fd00 r9:0000000000000008 r10:0000000000000008 r11:0000000000000246 r12:0000000000000000 r13:0000000000000000 r14:0000000000000000 r15:0000000000000000 Stack dump: 0x000000000053fdd8: 000000007b47a6a8 0000000000000000 0x000000000053fde8: 0000000000000000 0000000000000000 0x000000000053fdf8: 0000000000000000 0000000140000000 0x000000000053fe08: 00007fffffeaf000 0000000000000000 0x000000000053fe18: 0000000000000000 ffffffffffffffff 0x000000000053fe28: 000000007b4a7250 000000007b44c330 0x000000000053fe38: 0000000000000000 0000000000000000 0x000000000053fe48: 34e795fa6a2182c4 0000000000000000 0x000000000053fe58: 0000000000000000 0000000000000000 0x000000000053fe68: 0000000000000000 34e795fa6e4182c4 0x000000000053fe78: 34e763d2d9f182c4 0000000000000000 0x000000000053fe88: 0000000000000000 0000000000000000 Backtrace: =>0 0x0000000140000000 in helloworld (+0x0) (0x000000000053ffd0) 1 0x000000007b47a6a8 in kernel32 (+0x5a6a7) (0x000000000053ffd0) 0x0000000140000000: popq %r10 Modules: Module Address Debug info Name (18 modules) ELF 7b400000- 7b819000 Dwarf kernel32<elf> -PE 7b420000- 7b819000 \ kernel32 ELF 7bc00000- 7bd1f000 Deferred ntdll<elf> -PE 7bc20000- 7bd1f000 \ ntdll ELF 7c000000- 7c004000 Deferred <wine-loader> PE 140000000- 140006000 Export helloworld ELF 7fea078ae000- 7fea07ac0000 Deferred libnss_files.so.2 ELF 7fea07ac0000- 7fea07ccc000 Deferred libnss_nis.so.2 ELF 7fea07ccc000- 7fea07ee5000 Deferred libnsl.so.1 ELF 7fea07ee5000- 7fea080ee000 Deferred libnss_compat.so.2 ELF 7fea08cad000- 7fea08ec3000 Deferred libgcc_s.so.1 ELF 7fea08ec3000- 7fea091cc000 Deferred libm.so.6 ELF 7fea091cf000- 7fea093d3000 Deferred libdl.so.2 ELF 7fea093d4000- 7fea0979e000 Deferred libc.so.6 ELF 7fea0979e000- 7fea099bb000 Deferred libpthread.so.0 ELF 7fea099d6000- 7fea09d7c000 Dwarf libwine.so.1 ELF 7fea09d7d000- 7fea09fa5000 Deferred ld-linux-x86-64.so.2 ELF 7ffc02f6a000- 7ffc02f6b000 Deferred [vdso].so Threads: process tid prio (all id:s are in hex) 00000008 cmd.exe 00000009 0 0000000e services.exe 00000026 0 00000023 0 0000001e 0 00000018 0 00000013 0 00000010 0 0000000f 0 00000011 winedevice.exe 0000001b 0 00000017 0 00000016 0 00000012 0 0000001c plugplay.exe 00000020 0 0000001f 0 0000001d 0 00000021 winedevice.exe 0000002b 0 00000025 0 00000024 0 00000022 0 00000029 explorer.exe 0000002e 0 0000002d 0 0000002c 0 0000002a 0 0000002f (D) Z:\winebug\helloworld64\bin\HelloWorld.exe 00000030 0 <== System information: Wine build: wine-3.0.2 Platform: x86_64 Version: Windows 10 Host system: Linux Host version: 4.4.0-21-generic
https://bugs.winehq.org/show_bug.cgi?id=45864
Fabian Maurer dark.shadow4@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEEDINFO CC| |dark.shadow4@web.de Ever confirmed|0 |1
--- Comment #4 from Fabian Maurer dark.shadow4@web.de --- The crash you mentioned is fixed then using wine-3.16.
For me it works just fine when setting "-platform:x64" in the sample with the native dll.
Not sure why mono needs the platform to be explicit, maybe it should work with anycpu too. But not sure.
https://bugs.winehq.org/show_bug.cgi?id=45864
--- Comment #5 from Aaron Simmons paleozogt@gmail.com --- I tried it with wine-3.16 and its working for me also. Thanks!
https://bugs.winehq.org/show_bug.cgi?id=45864
Linards linards.liepins@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |linards.liepins@gmail.com
--- Comment #6 from Linards linards.liepins@gmail.com --- Is this issue regressed recently?
If not, I suggest the OP to RESOLVE as FIXED.