pycdc icon indicating copy to clipboard operation
pycdc copied to clipboard

"Error: vector" on Python 3.11-compiled code

Open xfoxfu opened this issue 2 years ago • 7 comments

# Source Generated with Decompyle++
# File: server.pyc (Python 3.11)

Error decompyling server.pyc: vector

Sample File: server.txt (extension changed to txt instead of original pyc)

xfoxfu avatar Nov 06 '23 06:11 xfoxfu

There are too many bytecodes in your pyc file, which makes analysis more difficult. If this error is reported, it should be that the array is out of bounds.

case Pyc::LOAD_GLOBAL_A:
            if (mod->verCompare(3, 11) >= 0) {
                if (operand & 1) {
                    /* Changed in version 3.11: 
                    If the low bit of "NAMEI" (operand) is set, 
                    then a NULL is pushed to the stack before the global variable. */
                    stack.push(nullptr);
                    /*
                    and thats because for some reason for example 3 global functions: input, int, print.
                    it tries to load: 1, 3, 5
                    all though we have only 3 names, so thats should be: (1-1)/2 = 0, (3-1)/2 = 1, (5-1)/2 = 2
                    i dont know why, maybe because of the null push, but thats a FIX for now.
                    */
                    operand = (int)((operand - 1) / 2);
                }
            }
            stack.push(new ASTName(code->getName(operand)));

This place attempts to obtain global variables, and the operand obtained is 458, but the length of the entire array is only 251, so it is out of bounds. Hope someone fixes it

ddouworld avatar Nov 07 '23 10:11 ddouworld

@ddouworld Thanks for your help. Now I see where to look from, and if I have time I would try to fix this.

xfoxfu avatar Nov 07 '23 16:11 xfoxfu

same isssue

gaplan avatar Nov 12 '23 06:11 gaplan

There is an issue with handling JUMP_FORWARD opcode in the routine named getConfig()

1362    JUMP_FORWARD                  3 (to 1370)

and some others...

also please note these opcodes still were not hanlded:

Warning: block stack is not empty!
Unsupported opcode: COPY
Unsupported opcode: SWAP
Unsupported opcode: COPY
Unsupported opcode: MAKE_CELL
Unsupported opcode: COPY
Unsupported opcode: MAKE_CELL
Unsupported opcode: MAKE_CELL
Unsupported opcode: SWAP
Unsupported opcode: MAKE_CELL
Unsupported opcode: COPY
Unsupported opcode: COPY
Unsupported opcode: COPY
Unsupported opcode: POP_JUMP_BACKWARD_IF_TRUE
Unsupported opcode: POP_JUMP_BACKWARD_IF_TRUE
Unsupported opcode: POP_JUMP_BACKWARD_IF_TRUE
Unsupported opcode: POP_JUMP_BACKWARD_IF_TRUE
Unsupported opcode: COPY
Unsupported opcode: POP_JUMP_BACKWARD_IF_TRUE
Unsupported opcode: COPY
Unsupported opcode: COPY
Unsupported opcode: COPY

I"m not sure how to implement COPY and SWAP opcodes that are working directly with the stack object

According to opcode logic they are doing something that violates stack paradigm principle:

image

anyway, here is my current decompilation result, though it is not 100% full, sorry

but I hope it'll help to fill in missed gaps!

https://www.sendspace.com/file/665viw del https://www.sendspace.com/delete/665viw/ce7dcfe54da0b68ec639eae4432dcb8e

greenozon avatar Nov 19 '23 20:11 greenozon

Do you have a time frame on getting this fixed? I am also seeing the same errors:

Source Generated with Decompyle++

File: Spirit_Calc.pyc (Python 3.11)

Unsupported opcode: JUMP_BACKWARD

Error decompyling <program_name>: vector

jimmy19712 avatar Dec 01 '23 15:12 jimmy19712

any sample python for this?

greenozon avatar Dec 01 '23 21:12 greenozon

I am also facing the same problem... someone please fix this 😫

NurTasin avatar Jan 09 '24 04:01 NurTasin

Should be fixed with #462

zrax avatar Feb 28 '24 23:02 zrax