pycdc
pycdc copied to clipboard
"./pycdc ./a.pyc" leads to Segmentation fault on mingw32/msys2
I use mingw32 from msys2 on windows 7 64bits to compile the latest code from https://github.com/zrax/pycdc
./pycdas.exe ./a.pyc
works well
however, ./pycdc.exe ./a.pyc
says Segmentation fault
the a.pyc
is from the belowing simple code
import math
for i in range(6):
print (math.sin(i))
I tested both PYCs by Python 2.7.12 |Anaconda 2.2.0 (32-bit)| (default, Jun 29 2016, 11:42:13)
and Python 3.4.4 |Anaconda 2.3.0 (64-bit)| (default, Feb 16 2016, 09:54:04)
. Everyone says Segmentation fault
.
only pycdc does not produce fault:
./pycdc.exe No input file specified
Errors in decompilation programs generally fall into these categories:
- the bytecode is something unexpected : different versions of Python add or remove bytecodes and even reassign bytecode numbers
- the sequence of bytecode is hard to untangle, especially due to various control-flow optimizations
What's weird here is that neither of the above apply here. pycdc definitely should be able to decompile this is simple program.
It does on GNU/Linux. So I think the problem is with mingw32 on windows 7 or compiling pycdc there.
At the risk of opening a can of worms, try decompiling using uncompyle6
I've also had issues with msys2 compiling with a similar error (Segmentation Fault), but after experimenting, the following steps allowed making a stable executable. They are (using ucrt64 as an environment)
pacman -S --needed git $MINGW_PACKAGE_PREFIX-{cmake,ninja,toolchain}
git clone https://github.com/zrax/pycdc.git
cd pycdc
cmake .
cmake --build .
./pycdc.exe test.pyc > test.py
copying pycdc elsewhere with the pycdc.exe+dlls (libgcc_s_seh-1.dll / libstdc++-6.dll / libwinpthread-1.dll from ucrc64/bin) allowed using it outside msys2 environment, directly in Windows. The isolated files worked in Windows 7, 10
how about making static linking? -> no any extra steps keeping dlls nearby
how about making static linking? -> no any extra steps keeping dlls nearby
I suspected that there are serious changes need, but thanks to this suggestion I changed the line in the CMakeLists.txt
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-error=shadow -Werror ${CMAKE_CXX_FLAGS}")
into
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-error=shadow -Werror -static ${CMAKE_CXX_FLAGS}")
and it seem to work. I'm not sure whether I can do this without messing up with the original CMakeLists. If there's a cmake option, I know I could pass it, but I'm not aware of a method to pass the compiler (-static
in this case) option directly.