rocky / python-uncompyle6

A cross-version Python bytecode decompiler
GNU General Public License v3.0
3.74k stars 408 forks source link

Program crashes on Windows Conda Python 3.x #477

Closed gkdiorflpgh04 closed 11 months ago

gkdiorflpgh04 commented 11 months ago

Description

This should be related to https://github.com/rocky/python-uncompyle6/issues/439 When a Python 2.7.3 .py file contains a very long list, decompilation fails. For example

m0_values = [
0.145163744688,
 0.0449195094407,
 -0.643097877502,
# .................
]

But using pycdc and uncompyle2 can decompile it successfully.

How to Reproduce

This compressed file contains 26193884.py and 26193884.pyc. The file 26193884.py was decompiled using pycdc, and it did not produce any errors. 26193884.zip

I am testing with the following code.

  with open("26193884.py", "w", encoding="utf-8") as f:
        uncompyle6.decompile_file("26193884.pyc", f)

Output Given

The test code above caused an error in my process. -1073741571 (0xC00000FD)

Environment

uncompyle6 77d7275 Python 3.10.4 Windows 11

rocky commented 11 months ago

I just tried decompling this locally on Ubuntu from a command-line and using the open() code and I am not seeing a problem in decompation.

The fact that you are getting that vague error message rather than information from the Python runtime with a stack trace leads me to believe something is weird about your environment or how this gets run from that code.

When you run this from a command-line does that error? When you run from a command-line using option "-a" does the output start:

 L.   2         0  LOAD_CONST               -1
                3  LOAD_CONST               ('hul_ai',)
                6  IMPORT_NAME           0  'custom.pub.ccom'
                9  IMPORT_FROM           1  'hul_ai'
               12  STORE_NAME            1  'hul_ai'
               15  POP_TOP          
             16_0  COLLECTION_START      0  'CONST_LIST'

 L.   3        16  ADD_VALUE             2  0.145163744688
               19  ADD_VALUE             3  0.0449195094407
               22  ADD_VALUE             4  -0.643097877502

?

rocky commented 11 months ago

While I appreciate the fact that you looked at other problems for similarities, I do not see that these are related yet.

That issue had to do with the types of the list values getting confused between variable names and strings as list elements. There is no evidence this is going on here.

Also, there is no report that things crashed let alone a stack trace.

gkdiorflpgh04 commented 11 months ago

Thank you for your response.

When I run from a command-line using option "-a",I did indeed receive the output you mentioned. But when I don't use -a, the result is as follows.

(venv) PS C:\test> uncompyle6 .\26193884.pyc   
# uncompyle6 version 3.9.0
# Python bytecode version base 2.7 (62211)
# Decompiled from: Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]
# Embedded file name: custom\pub\helper\RL\runtime_models\model_1002000_cpp.py
(venv) PS C:\test> 

In order to better describe the problem, I conducted the following tests.

  1. new a python 3.10.4 venv
  2. pip install uncompyle6
  3. run
    
    import uncompyle6

def main(): uncompyle6.decompile_file("26193884.pyc")

if name == 'main': main()

I have obtained the following results.
```conlose
C:\test\venv\Scripts\python.exe C:\test\main.py 
# uncompyle6 version 3.9.0
# Python bytecode version base 2.7 (62211)
# Decompiled from: Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]
# Embedded file name: custom\pub\helper\RL\runtime_models\model_1002000_cpp.py

Process finished with exit code -1073741571 (0xC00000FD)
gkdiorflpgh04 commented 11 months ago

I'm sorry, I think this issue can be closed now. After creating a Python 2.7 environment using conda, it is working fine.

But even when creating a new 3.10 or 3.8 environment using conda, it still doesn't work properly.

Process finished with exit code -1073741571 (0xC00000FD)

gkdiorflpgh04 commented 11 months ago

I'm sorry, but I still think this is an issue because the uncompyle6 version in 2.7 is outdated. I believe there are still problems with this pyc file even in the version 3.9.0 of uncompyle6. @rocky

rocky commented 11 months ago

You need to prove it then.

gkdiorflpgh04 commented 11 months ago

Thank you, I have made the following attempts.

  1. Createnew Python environment.
  2. pip install uncompyle6
  3. run uncompyle6.decompile_file("28856229.pyc", outstream=sys.stdout)

The conclusion is that this pyc file can only be decompiled correctly in a Python 2 environment,

And when I decompile another pyc file using Python 2, its docstring is displayed as something like "\xe8\x8e\xb7\xe5\x8f\x96\xe4\xb8\x8b\xe4".

I used uncompyle6 3.9.0 throughout the process.

in python 3.10 3.9 3.8 3.6, Output like this:

# uncompyle6 version 3.9.0
# Python bytecode version base 2.7 (62211)
# Decompiled from: Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]
# Embedded file name: custom\pub\helper\RL\runtime_models\model_1002000_cpp.py

Process finished with exit code -1073741571 (0xC00000FD)

In Python 2.7, it can decompile the source code normally,But the docstring displays incorrectly.

@rocky

gkdiorflpgh04 commented 11 months ago

After further testing

it was found that the program works fine on Ubuntu regardless of whether Python 2 or Python 3 is used.

However, it does not work on Windows.

I assure you that this is not due to my personal environment configuration issue.

I'm not sure if this question belongs to Python or this project. I hope to get your answer.

rocky commented 11 months ago

(Re)read the the last paragraph of https://github.com/rocky/python-uncompyle6/blob/master/HOW-TO-REPORT-A-BUG.md#the-importance-of-your-bug-report

Private consulting rates are listed at the bottom of the page and here: https://github.com/rocky