pyarmor icon indicating copy to clipboard operation
pyarmor copied to clipboard

[BUG] `Too many function arguments, the program crashes`

Open 17Reset opened this issue 1 year ago • 9 comments

When there are too many function arguments, the program crashes with no output error after encryption with pyarmor. I have a PyQt6 program, I put the menu production in a function, part of the content is shown below, after testing, when the function parameters passed too much, using pyarmor after confusing the code can not be used normally, I use the command is:

pyarmor cfg data_files=*
pyarmor gen --recursive --enable-bcc --obf-code 2 --output xapp_dist_pyarmor xapp_workspace

In the following example, if my argument is passed into the callback13 position, the muddled code still runs, but when one more argument is passed, it starts to crash without any error output

def rtl_source(
        menu,
        item_type,
        top_module,
        check_status,
        callback1,
        callback2,
        callback3,
        callback4,
        callback5,
        callback6,
        callback7,
        callback8,
        callback9,
        callback10,
        callback11,
        callback12,
        callback13,
        # callback14,
        # callback15,
        # callback16,
        # callback17,
        # callback18,
        # callback19,
        # callback20,
):
 pass

17Reset avatar Jun 18 '24 14:06 17Reset

When the --enable-bcc option is not used, the pyarmor obfuscated program works fine

17Reset avatar Jun 18 '24 14:06 17Reset

Reproduced, I'll check it and fix it when I'm back office next Monday.

jondy avatar Jun 19 '24 09:06 jondy

What's your platform? This issue is reproduced in darwin.arm64, but not in darwin.x86_64.

jondy avatar Jun 24 '24 01:06 jondy

Platform windows.x86_64

17Reset avatar Jun 25 '24 06:06 17Reset

I made a mistake, the crash in darwin.arm64 is codesign issue, not bcc issue.

And I can't reproduce this issue in Windows 7 (x86_64) by Python 3.7 and 3.8

The test script is t1841.py

def rtl_source(
          menu,
          item_type,
          top_module,
          check_status,
          callback1,
          callback2,
          callback3,
          callback4,
          callback5,
          callback6,
          callback7,
          callback8,
          callback9,
          callback10,
          callback11,
          callback12,
          callback13,
          callback14,
          callback15,
          callback16,
          callback17,
          callback18,
          callback19,
          callback20,
):

     print(
          menu,
          item_type,
          top_module,
          check_status,
          callback1,
          callback2,
          callback3,
          callback4,
          callback5,
          callback6,
          callback7,
          callback8,
          callback9,
          callback10,
          callback11,
          callback12,
          callback13,
          callback14,
          callback15,
          callback16,
          callback17,
          callback18,
          callback19,
          callback20,
     )

if __name__ == '__main__':
     args = list(range(24))
     rtl_source(*args)

The test steps:

pyarmor gen --enable-bcc t1841.py
python3 dist/t1841.py

It works fine in test env.

jondy avatar Jun 25 '24 10:06 jondy

windows Platform: windows11 Windows.x86_64 Pyarmor version: Pyarmor 8.5.9 Python version: 3.12.4 All callbacks in the above example use lambda functions

17Reset avatar Jun 25 '24 13:06 17Reset

Does it work or not with my test script and test steps in your environments?

Actually I guess it's not too many arguments issue, but something else.

jondy avatar Jun 26 '24 07:06 jondy

At least in my example, it is caused by too many arguments, and when a certain number is reached, there will be a crash.

17Reset avatar Jun 27 '24 14:06 17Reset

Is the code snippet shown above in PyQt6.

17Reset avatar Jun 27 '24 14:06 17Reset