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

[BUG] continue dont work in while loop with enable-bcc #2023

Closed
njockfatmih opened this issue Dec 28, 2024 · 8 comments
Closed

[BUG] continue dont work in while loop with enable-bcc #2023

njockfatmih opened this issue Dec 28, 2024 · 8 comments
Labels

Comments

@njockfatmih
Copy link

njockfatmih commented Dec 28, 2024

def generator():
    counter = 0
    while 1:
        print(f"Counter: {counter}")
        counter+=1
        if counter > 100: return "success"
        for i in range(5):
            if 1:
                try: pass
                except: pass
            else:
                try: pass
                except: pass
        print("CONTINUE")
        continue
result = generator()
print(f"Result: {result}")

I have simplified my code to the limit to make it clear. In this code, after continue the function terminates for some unknown reason (exactly if you use --enable-bcc) if you just run the script it will return "success"
If you remove the loop - everything works with pyarmor --enable-bcc.
If you remove one try block - everything works with pyarmor --enable-bcc
If you remove one else block - everything works with pyarmor --enable-bcc.
This particular code construction does not work. I really want to use bcc, but I'm afraid that the same problem may occur on other code sections of a large project.
p.s. I understand that continue is not needed at the end, in the original code it is triggered by a condition and if the condition is not triggered, the other code works.

pyarmor line: pyarmor generate "test.py" --enable-bcc --output "build"
pyarmor version 9.0.6 (pro)
python version 3.9.13

@jondy
Copy link
Contributor

jondy commented Dec 29, 2024

I'll check it

@jondy
Copy link
Contributor

jondy commented Dec 29, 2024

I can't reproduce this issue.

What I test is using this script tsrc/bugs/t2023.py

def generator():
    counter = 0
    while 1:
        print(f"Counter: {counter}")
        counter+=1
        if counter > 100: return "success"
        for i in range(5):
            if 1:
                try: pass
                except: pass
            else:
                try: pass
                except: pass
        print("CONTINUE")
        continue

result = generator()
print(f"Result: {result}")

And test is with

python3.9 -m pyarmor.cli --enable-bcc tsrc/bugs/t2023.py
python3.9 dist/t2023.py

It works fine, print

...
CONTINUE
Counter: 99
CONTINUE
Counter: 100
Result: success

@njockfatmih
Copy link
Author

njockfatmih commented Dec 29, 2024

I did it on windows. I have tried clang 9.0 and clang latest version and the result is the same "Result: None". Can you tell me what other programs might have been involved at the time of obfuscation?
I also tried this on python 3.13.1 - the result is the same

@njockfatmih
Copy link
Author

I thought it was a windows problem. No, I installed a clean ubuntu 24 and pyarmor failed again. The script is the same, the line parameters are the same as yours. Tried different versions of pyarmor - same thing.

@njockfatmih
Copy link
Author

I want to specify that I use pro license without ci/cd. Maybe on version 9 with "pro" license pyarmor-8 is used regardless of the library version

@jondy
Copy link
Contributor

jondy commented Dec 30, 2024

It's fine in Darwin.x86_64.

Reproduced it in Ubuntu.

I'll check it.

@jondy
Copy link
Contributor

jondy commented Dec 30, 2024

This bug has been fixed in latest version v9.0.7

@njockfatmih
Copy link
Author

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants