Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Parse error at or near `JUMP_FORWARD' instruction #150

Closed
wangym5106 opened this issue Jan 23, 2018 · 5 comments
Closed

Parse error at or near `JUMP_FORWARD' instruction #150

wangym5106 opened this issue Jan 23, 2018 · 5 comments
Labels
Control Flow Problem has to do with bad control-flow detection Python 2.x Python 2.7

Comments

@wangym5106
Copy link
Contributor

Python bytecode version: 2.7, compiled with 2.7.10
uncompyle6 71e7120 on Python 3.6.4

Code example:

def func(a):
    if a:
        return True
        something_never_run()

Instruction context:

   2       0  LOAD_FAST             0  'a'
           3  POP_JUMP_IF_FALSE    20  'to 20'

   3       6  LOAD_GLOBAL           0  'True'
           9  RETURN_VALUE

   4      10  LOAD_GLOBAL           1  'something_never_run'
          13  CALL_FUNCTION_0       0
          16  POP_TOP
          17  JUMP_FORWARD          0  'to 20'
        20_0  COME_FROM            17  '17'

This is a rare condition but this code is valid. Thanks.

@rocky rocky added Duplicate Issue has been raised in another issue Control Flow Problem has to do with bad control-flow detection Python 2.7 Python 2.4 and removed Duplicate Issue has been raised in another issue Python 2.4 labels Jan 23, 2018
@rocky
Copy link
Owner

rocky commented Jan 23, 2018

With respect to the recent 2.7 failures, although I think each can be fixed in the current framework, what is really needed is a refactor of the code: separate pass using control-flow analysis over the instructions to mark and insert additional instructions which delimit the control flow structures.

My current thought is to do create a branch for 3.6 or maybe a separate project to strip the code down to just that version and then work on that aspect. (3.6 probably has the worst handling of control flow while the overall handling of instructions for 3.x is a little cleaner than for 2.x).

However it could also be done in 2.7 or some other version. If you or someone else wants to jump in to handle the refactor that would be most appreciated. Otherwise I'll probably will defer these kinds of issues for a little while.

@wangym5106
Copy link
Contributor Author

I want to help but I don't have much knowledge on compiling and decompiling. I'll try to get familiar with compiler tech and this project.

@rocky
Copy link
Owner

rocky commented Jan 24, 2018

That's the spirit! No one is born knowing compiling or decompiling. And the particular method used here I think is a little bit new and different even if you were familiar with decompiling.

The wiki has a bit of information on how the code works. https://github.com/rocky/python-uncompyle6/wiki/How-does-this-code-work%3F is the oldest and shortest version. https://github.com/rocky/python-uncompyle6/wiki/Deparsing-Paper.pdf has the most detailed information but it is a little bit like a research paper.

One thing you might do to see what's up is see if you can fix this particular bug using the existing code. Since this does work with the older uncompyle2, run that with the --show-ast option to look at the grammar it gives for this program.Then try to reconcile that with uncompyle6 when compiled for Python 3 bytecode. (Earlier Python 3 bytecode like 3.3 will match what 2.7 is supposed to do more closely than later versions). The option to use when decompiling for debugging is -agt.

If you have questions, jut ask.

@rocky
Copy link
Owner

rocky commented Jan 28, 2018

In commit 5edcc7c , I believe this issue is fixed. So you and other might get a sense of what was done, I tracked the steps that I took and those are in the wiki: https://github.com/rocky/python-uncompyle6/wiki/Fixing-Issue-%23150

@wangym5106
Copy link
Contributor Author

Thanks! That's very helpful.

@rocky rocky closed this as completed Jan 29, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Control Flow Problem has to do with bad control-flow detection Python 2.x Python 2.7
Projects
None yet
Development

No branches or pull requests

2 participants