Segmentation fault under QEMU / armv7l
Been using pyarmor for the last couple of years without any issues. Recently, I moved all code to a new machine (Ryzen 5900X) and install QEMU with Debian buster on it with armv7 architecture. This actually did work for a while but today I started receiving all kinds of segmentation faults when running pyarmor.
I purchased pyarmor.
Version: Tried both release (6.7.4) and From Github (6.7.5)
uname -a: Linux workshop 5.13.6-051306-generic #202107291324-Ubuntu SMP Thu Jul 29 13:34:02 UTC 2021 armv7l GNU/Linux
I deleted .pyarmor directory and then ran:
jasem@workshop:~$ pyarmor -d register pyarmor-regfile-1.zip
DEBUG PyArmor installation path: /usr/local/lib/python3.7/dist-packages/pyarmor-6.7.5-py3.7.egg/pyarmor
DEBUG PyArmor home path: /home/jasem/.pyarmor
INFO Create pyarmor home path: /home/jasem/.pyarmor
INFO Create trial license file: /home/jasem/.pyarmor/license.lic
DEBUG Native platform is linux.armv7
DEBUG Search dynamic library in the path: /usr/local/lib/python3.7/dist-packages/pyarmor-6.7.5-py3.7.egg/pyarmor/platforms
DEBUG Search dynamic library in the path: /home/jasem/.pyarmor/platforms
INFO Create cross platform libraries path /home/jasem/.pyarmor/platforms
INFO Search library for platform: linux.armv7
DEBUG Load platform list from /home/jasem/.pyarmor/platforms/index.json
WARNING The trial version could not download the latest platform library
INFO Getting remote file: https://github.com/dashingsoft/pyarmor-core/raw/r41.15a/platforms/index.json
INFO Write cached platform list file /home/jasem/.pyarmor/platforms/index.json
WARNING The trial version could not download the latest core libraries, tag r41.15a is always used
WARNING The core library excepted version is r44.18, but got r41.15a from platform list file /home/jasem/.pyarmor/platforms/index.json
INFO Found available libraries: ['linux.armv7.3']
INFO Target path for linux.armv7.3: /home/jasem/.pyarmor/platforms/linux/armv7/3
INFO Downloading library file for linux.armv7.3 ...
WARNING The trial version could not download the latest platform library
INFO Getting remote file: https://github.com/dashingsoft/pyarmor-core/raw/r41.15a/platforms/armv7/_pytransform.so
INFO Writing target file: /home/jasem/.pyarmor/platforms/linux/armv7/3/_pytransform.so
INFO Download dynamic library linux.armv7.3 OK
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault
After this, any command (except for pyarmor -h) results in a segmentation fault:
jasem@workshop:~$ pyarmor -d -v
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault
Please remove this folder,
rm -rf /home/jasem/.pyarmor/platforms
Then use platform linux.armv7.0,
export PYARMOR_PLATFORM=linux.armv7.0
pyarmor ...
Thanks! That fixed it. However, the build process I had builds for 3 targets platforms (armv7, aarch64, and x86-64, all linux):
pyarmor obfuscate --platform linux.aarch64.3 text.py
INFO PYARMOR_PLATFORM is linux.armv7.0
INFO PyArmor Version 6.7.5
INFO Python 3.7.3
INFO Target platforms: ['linux.aarch64.3']
INFO Update target platforms to: ['linux.aarch64.3']
INFO ====================================================
INFO Reload PyArmor with platform: linux.armv7.3
INFO ====================================================
INFO PYARMOR_PLATFORM is linux.armv7.3
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
It used to produce for all 3 architectures without issues using the --platform flag.
I don't suppose I need to use export PYARMOR_PLATFORM for each target platform I'm building for?
The problem is linux.armv7.3 doesn't work in your QEMU, only linux.armv7.0 works, refer to
https://pyarmor.readthedocs.io/en/latest/advanced.html#obfuscating-scripts-with-different-features
One solution is to obfuscate all the scripts with feature 0, for example, linux.aarch64.0, but it will reduce the security level.
So I suggest you obfuscate the scripts in the any x86-64 platform, it will obfuscate the scripts with feature 3 by default.
Please also read this section https://pyarmor.readthedocs.io/en/latest/platforms.html#features