You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Packaged app compressed with UPX crashes at startup in Windows x64 #4178
If I use UPX, my app crashes as soon as it starts (there's no console output when I use cmd.exe). Weird thing is, bundled app with --onefile works with no issues (files seem to be compressed, *.exe is smaller when I use UPX if I recall correctly).
Everything works well in Windows 7 x86 too.
According to Windows 7 error message, "ucrtbase.dll" fails but according to Windows 10 (x64) error message, "vcruntime140.dll" does, so the workaround is easy: replacing each faulty *.dll file with its non-compressed version. It solves the problem but somewhat extensive testing is would be needed.
Have no tried Windows 8 yet.
OS: Windows 7 x64 UPX: 3.95 (x64 and x86), 3.94 and 3.93 Python: 3.7.3 x86 fresh install Pyinstaller: 3.4 and 3.5dev0+b54a15d72e (no cache files) Test toy code:
import os
print("hola")
os.system("pause")
A "hello world" app works though.
I'm new to GitHub so if there's something else I should do or test just tell me.
And thank you very very much for your hard work on PyInstaller!
With Pyinstaller 4.2 I see the nice message Disabling UPX for c:\program files\python39\VCRUNTIME140_1.dll due to CFG! and no longer receive the error above!
Still doesn't load when using UPX due to PyQT5 error of qt.qpa.plugin: Could not find the Qt platform plugin "windows" in "" but I am guessing that is something entirely different sigh
Still doesn't load when using UPX due to PyQT5 error of qt.qpa.plugin: Could not find the Qt platform plugin "windows" in "" but I am guessing that is something entirely different sigh
That's due to upx/upx#107 (which is specific to Qt plugins and unrelated to CFG).
I suppose if we wanted to work around it, we'd need to exempt Qt5 plugins from UPX-processing. Either via hard-coded list, or by implementing a mechanism that would allow hooks to specify list(s) of files to exempt from UPX (and then have PySide2 and PyQt5 hooks exempt their Qt5 plugins).
I'm just writing this so that this issue doesn't get buried (again). To properly fix this we need either of Rok's solutions (preferably the second IMO) or for the UPX issue to be fixed their end.
Would it be possible to detect these automatically as well @rokm?
Unfortunately, I don't think so. The automatic exclusion we have so far is based on characteristics that are known to break with UPX (i.e., CFG being enabled on a DLL, or a DLL being a Qt plugin). This does not seem to be the case with 32-bit Qt5 DLLs (and python extensions), so the only thing we could possibly do is automatically exclude everything that comes from PyQt5 or PySide2 folders (and their Qt6 equivalents) on 32-bit Windows/python.
Is the failure mode for this specific case known? I.e., is it documented anywhere why 32-bit Qt5 DLLs are problematic when used with upx?
Is the failure mode for this specific case known? I.e., is it documented anywhere why 32-bit Qt5 DLLs are problematic when used with upx?
No, I just found this out by excluding all pyside dlls and then replacing them one after the other with the UPX packed ones. I don't know if 32 bit builds are worth to invest time in if you don't see a low-hanging fruit immediately .
Also note how I didn't have to exclude qtsvg.pyd or qtxml.pyd, I wonder what makes these different ...
Activity
cdgriffith commentedon Aug 26, 2020
I am experiencing the same issue on Windows 10, UPX 3.86. Using console and onefile.
ucrtbase.dll is not designed to run on Windows...Error status: 0xc000007b
bwoodsend commentedon Feb 1, 2021
I suspect that this was fixed by #5382?
cdgriffith commentedon Feb 1, 2021
With Pyinstaller 4.2 I see the nice message
Disabling UPX for c:\program files\python39\VCRUNTIME140_1.dll due to CFG!and no longer receive the error above!Still doesn't load when using UPX due to PyQT5 error of
qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""but I am guessing that is something entirely different sighrokm commentedon Feb 1, 2021
That's due to upx/upx#107 (which is specific to Qt plugins and unrelated to CFG).
I suppose if we wanted to work around it, we'd need to exempt Qt5 plugins from UPX-processing. Either via hard-coded list, or by implementing a mechanism that would allow hooks to specify list(s) of files to exempt from UPX (and then have PySide2 and PyQt5 hooks exempt their Qt5 plugins).
cdgriffith commentedon Feb 1, 2021
Thanks for the link, will watch that one! UPX is not a make or break deal for me, but I am happy to help test my code with any changes around it.
For this ticket probably prudent to see if @MyDataIsReady responds soon, otherwise good to close from my point of view.
MyDataIsReady commentedon Feb 1, 2021
Seems to be working! Just tried with Windows 10 x64, Python 3.8.7 and Pyinstaller 4.2.
Thanks!
bwoodsend commentedon Feb 2, 2021
I'm just writing this so that this issue doesn't get buried (again). To properly fix this we need either of Rok's solutions (preferably the second IMO) or for the UPX issue to be fixed their end.
building: automatically exclude Qt plugins from upx processing
building: automatically exclude Qt plugins from upx processing
building: automatically exclude Qt plugins from upx processing
henzef commentedon Jun 26, 2021
I had to exclude the following as well when using 32 bit python:
Would it be possible to detect these automatically as well @rokm?
rokm commentedon Jun 27, 2021
Unfortunately, I don't think so. The automatic exclusion we have so far is based on characteristics that are known to break with UPX (i.e., CFG being enabled on a DLL, or a DLL being a Qt plugin). This does not seem to be the case with 32-bit Qt5 DLLs (and python extensions), so the only thing we could possibly do is automatically exclude everything that comes from PyQt5 or PySide2 folders (and their Qt6 equivalents) on 32-bit Windows/python.
Is the failure mode for this specific case known? I.e., is it documented anywhere why 32-bit Qt5 DLLs are problematic when used with
upx?henzef commentedon Jun 28, 2021
No, I just found this out by excluding all pyside dlls and then replacing them one after the other with the UPX packed ones. I don't know if 32 bit builds are worth to invest time in if you don't see a low-hanging fruit immediately .
Also note how I didn't have to exclude qtsvg.pyd or qtxml.pyd, I wonder what makes these different ...
rokm commentedon Jun 28, 2021
Do you really have to exclude
qtcore.pyd,qtgui.py, andqtwidgets.pyd, though?henzef commentedon Jun 28, 2021
yes