Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSError : [Errno 8] Bad EXE format for %1 #79

Open
iwTao opened this issue Dec 16, 2021 · 13 comments
Open

OSError : [Errno 8] Bad EXE format for %1 #79

iwTao opened this issue Dec 16, 2021 · 13 comments
Labels

Comments

@iwTao
Copy link

iwTao commented Dec 16, 2021

hello,i have a DLL file needed load by zurbruecke in Ubuntu, but when i loading file use zugbruecke.windll.LoadLibrary, python will report [Errno 8] Bad EXE format for %1to me. What should I do for this Error?

@s-m-e
Copy link
Member

s-m-e commented Dec 18, 2021

Can you configure the log_level to its maximum of 10 and post the complete output?

@s-m-e s-m-e added the question label Dec 18, 2021
@iwTao
Copy link
Author

iwTao commented Dec 19, 2021

There is the log

(1639896579.08/877d3127) UNIX o: [session-client] STARTING (STAGE 1) ...
(1639896579.09/877d3127) UNIX o: [session-client] Configured Wine-Python version is 3.5.3 for win32.
(1639896579.09/877d3127) UNIX o: [session-client] Log socket port: 39819.
(1639896579.09/877d3127) UNIX o: [session-client] STARTED (STAGE 1).
(1639896579.09/877d3127) UNIX o: [session-client] STARTING (STAGE 2) ...
(1639896579.09/877d3127) UNIX o: [interpreter] STARTING ...
(1639896579.09/877d3127) UNIX o: [interpreter] Command: wine /root/.zugbruecke/win32-python3.5.3/python.exe /usr/local/lib/python3.6/site-packages/zugbruecke/_server_.py --id 877d3127 --port_socket_wine 57203 --port_socket_unix 39819 --log_level 10 --log_write 1
(1639896579.09/877d3127) UNIX o: [interpreter] Started with PID 5251.
(1639896579.18/877d3127) UNIX o: [interpreter] Logging threads started.
(1639896579.18/877d3127) UNIX o: [interpreter] STARTED.
(1639896579.18/877d3127) UNIX o: [session-client] Waiting for session-server to be up ...
(1639896579.34/877d3127) WINE o: [session-server] STARTING ...
(1639896579.34/877d3127) WINE o: [mp-server] STARTING ...
(1639896579.34/877d3127) WINE o: [mp-server] Log attached.
(1639896579.34/877d3127) WINE o: [mp-server] STARTED.
(1639896579.34/877d3127) WINE o: [session-server] ctypes server is listening on port 57203.
(1639896579.34/877d3127) WINE o: [session-server] STARTED.
(1639896579.35/877d3127) WINE o: [session-server] Serve forever ...
(1639896579.36/877d3127) UNIX o: [session-client] ... session server is up (after 0.17 seconds).
(1639896579.36/877d3127) UNIX o: [session-client] STARTED (STAGE 2).
(1639896579.36/877d3127) UNIX o: [session-client] Attaching to DLL file "/home/klipper-us/uwc400/UWC4000.dll" with calling convention "windll" ...
(1639896579.36/877d3127) WINE o: [session-server] Attaching to DLL file "/home/klipper-us/uwc400/UWC4000.dll" with calling convention "windll" ...
(1639896579.36/877d3127) WINE o: [session-server] ... failed!
(1639896579.36/877d3127) UNIX o: [session-client] ... failed!

@s-m-e
Copy link
Member

s-m-e commented Dec 19, 2021

Thanks.

It could be a DLL that uses a different "calling convention". Try cdll instead of windll (although this error should not show at the time of attaching to the DLL but only a little later).

Or, most likely, it could be a 32 bit vs 64 bit issue. zugbruecke runs Wine in 32 bit mode by default. You can configure zugbruecke to run in 64 bit mode, assuming that you are dealing with a 64 bit DLL file.

Last but not least, I'd suspect that there is some issue with UWC4000.dll itself. It could simply be a broken/corrupted file.

@jayhop
Copy link

jayhop commented Mar 25, 2022

Hi @s-m-e.
I have a similar issue. Using cdll instead of windll results in the following error:

import zugbruecke
dll_path = './test.dll'
isolib = zugbruecke.cdll.LoadLibrary(dll_path)
OSError: ./test.dll: invalid ELF header

Your other suggestion leads to the same error

import zugbruecke

zugbruecke.session({"log_level": 10, "arch": 'win64'})
dll_path = './test.dll'
isolib = zugbruecke.windll.LoadLibrary(dll_path)
(1648216507.31/bd1b8f2d) UNIX o: [session-client] STARTING (STAGE 1) ...
(1648216507.31/bd1b8f2d) UNIX o: [session-client] Configured Wine-Python version is 3.5.3 for win64.
(1648216507.31/bd1b8f2d) UNIX o: [session-client] Log socket port: 51263.
(1648216507.31/bd1b8f2d) UNIX o: [session-client] STARTED (STAGE 1).
OSError: [Errno 8] Bad EXE format for %1
(1648216514.82/bd1b8f2d) UNIX o: [session-client] TERMINATING ...
(1648216514.82/bd1b8f2d) UNIX o: [session-client] TERMINATED.

System information

  • zugbruecke 0.0.15
  • python 3.10.2
  • wine 7.4-1
  • wine-mono 7.1.1-1
  • OS Manjaro/Linux 21.2.5

@s-m-e
Copy link
Member

s-m-e commented Mar 25, 2022

@jayhop Interesting. Would you be able to share a reproducible example, i.e. code and the DLL, with me - so I can have a closer look at it directly?

@jayhop
Copy link

jayhop commented Mar 28, 2022

Unfortunately, I can't due to copyright issues. I'll try to create and post another example later this week or next.

@s-m-e
Copy link
Member

s-m-e commented Jun 28, 2022

@jayhop and @iwTao If your examples can be discussed under NDA perhaps feel free to reach out. I am still looking for a reliable way to reproduce this bug.

@jayhop
Copy link

jayhop commented Aug 24, 2022

@s-m-e Sorry for my late reply! I've added you to a private repo. I hope you can reproduce this bug.

@s-m-e
Copy link
Member

s-m-e commented Aug 24, 2022

@jayhop Thanks! Will look into it.

@s-m-e
Copy link
Member

s-m-e commented Sep 11, 2022

@jayhop Did a lot of cleanup, repaired CI etc and will release v0.1.0 today. I'll use this to bisect your issue.

@jayhop
Copy link

jayhop commented Sep 12, 2022

@jayhop Did a lot of cleanup, repaired CI etc and will release v0.1.0 today. I'll use this to bisect your issue.

Thanks for the update 🙏.

@s-m-e
Copy link
Member

s-m-e commented Sep 13, 2022

@jayhop Findings so far: zugbruecke wont attach to your DLL file. However, it's not zugbruecke itself, it is ctypes underneath that does not want to. zugbruecke (on Linux) correctly reports what ctypes (on Wine) complains about. I have started a Windows version of Python on top of Wine directly, effectively eliminating zugbruecke from the equation - same result. It is worth noting that (C)Python changed its FFI (foreign function interface) implementation between versions 3.7 and 3.8. In other words, the mechanism that ctypes depends on changed between those two versions. Interestingly, both throw different exceptions, but ultimately, both do not want to attach to your DLL. I have one last thing on my list, testing this on an actual Windows system, but I suspect that your DLL is somehow broken or uses some non-standard interface mechanism.

@jayhop
Copy link

jayhop commented Sep 21, 2022

@s-m-e that's suprising. Is it possible that the library VCRUNTIME140_APP.dll is missing in wine? Since my DLL depends on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants