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

Missing "While True" #485

Open
hikali8 opened this issue Mar 5, 2024 · 4 comments
Open

Missing "While True" #485

hikali8 opened this issue Mar 5, 2024 · 4 comments
Labels
Control Flow Problem has to do with bad control-flow detection Python 3.8 Volunteer wanted Volunteer wanted to fix if a bug or to implement if a new feature. Works on decompyle3

Comments

@hikali8
Copy link

hikali8 commented Mar 5, 2024

Description

"While True" will disappear if a "if" branch is indirectly under it

How to Reproduce

import time

L = ['a', 's']
def thread():
    while True:
        for c in L:
            if c == 'a':
                return
        time.sleep(0.5)

Output Given

# uncompyle6 version 3.9.1.dev0
# Python bytecode version base 3.8.0 (3413)
# Decompiled from: Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
# Embedded file name: simple.py
# Compiled at: 2024-03-05 23:05:50
# Size of source mod 2**32: 157 bytes
import time
L = ["a", "s"]

def thread():
    for c in L:
        if c == "a":
            return             return None
        time.sleep(0.5)

Expected behavior

def thread():
+    while True:
+        for c in L:
+            if c == "a":
+                return
-    for c in L:
-        if c == "a":
-            return             return None
        time.sleep(0.5)

Environment

  • Uncompyle6 version: output from uncompyle6 --version uncompyle6 3.9.1.dev0
  • xdis version: output from pydisasm --version pydisasm, version 6.1.0.dev0
  • Python version for the version of Python the byte-compiled the file: python -c "import sys; print(sys.version)" where python is the correct CPython or PyPy binary.
    3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
  • OS and Version: Windows 11 (23H2)
@rocky
Copy link
Owner

rocky commented Mar 5, 2024

I believe this works okay on the newer version of this that is specialized or Python 3.8 (and 3.7), called decompyle3.

@rocky rocky added Duplicate Issue has been raised in another issue Control Flow Problem has to do with bad control-flow detection Python 3.8 Volunteer wanted Volunteer wanted to fix if a bug or to implement if a new feature. Works on decompyle3 and removed Duplicate Issue has been raised in another issue labels Mar 5, 2024
@rocky
Copy link
Owner

rocky commented Mar 5, 2024

@hikali8 (or anyone wanting to fix): If you are up for it see why "COME_FROM" at the very top is missing in this code base while it is correctly added in decompyle3.

@hikali8
Copy link
Author

hikali8 commented Mar 5, 2024

@hikali8 (or anyone wanting to fix): If you are up for it see why "COME_FROM" at the very top is missing in this code base while it is correctly added in decompyle3.

Thank you rocky, I just tested that code in decompyle3 and it was intactly printed, so I will likely be observing decompyle3 and figuring out the cream in it

@rocky
Copy link
Owner

rocky commented Mar 5, 2024

I will likely be observing decompyle3 and figuring out the cream in it

Great - thanks! The options that will display a lot of information regarding the thought processes the decompilers use is -AgT, for example

decompyle3 -AgT  bug-while.pyc 

I will be giving a talk on these decompilers at Blackhat Asia 2024
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Control Flow Problem has to do with bad control-flow detection Python 3.8 Volunteer wanted Volunteer wanted to fix if a bug or to implement if a new feature. Works on decompyle3
Projects
None yet
Development

No branches or pull requests

2 participants