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

reopen: stack size computation is broken #3 #5

Open
peterazmanov opened this issue Oct 26, 2015 · 8 comments
Open

reopen: stack size computation is broken #3 #5

peterazmanov opened this issue Oct 26, 2015 · 8 comments

Comments

@peterazmanov
Copy link
Collaborator

I encountered the 'closed' issue reported by @pwaller with Python 3.4. Stack size computation is broken (method '_compute_stacksize') and returns zero for every block of code I tried. As I mentioned in comment of original issue I tried to fix it (peterazmanov/byteplay). My changes stopped crashes, but the code requires further testing.

@peterazmanov
Copy link
Collaborator Author

From 2cc5ce4 there shouldn't be crashes or debug breaks associated with the size of stack.

P.S. Still in some cases '_compute_stacksize' returns more than needed (see issue in my fork for details)

@pwaller
Copy link

pwaller commented Feb 4, 2016

xref #3

@peterazmanov
Copy link
Collaborator Author

I believe current version for Python 2 (byteplay2.py) still containes broken stack size calculation... (original issue was reported for Python 2 version and nothing has been fixed in it) I propose to substitute byteplay2.py with base version by Noam Yorav-Raphael

@serprex
Copy link
Owner

serprex commented Feb 21, 2016

An important modification I made to the stack calculation is that we take the maximum stack usage if two branches with different stack usage combine & then return without looping

@peterazmanov
Copy link
Collaborator Author

I don't quite understand your improvement. The original version doesn't contain looping, it calculates stack depth for every possible scope (including loop scopes).

Besides, after your changes stack depth calculation returns 0, at least sometimes (confirmed by @pwaller with Python 2, and by me with Python 3.4 for other test case).

@serprex
Copy link
Owner

serprex commented Feb 21, 2016

I mean the bytecode looping. ie

JUMP_IF_FALSE L1
PUSH 1
L1:
RET

Should be allowed to compile

@peterazmanov
Copy link
Collaborator Author

What do you mean by "bytecode looping"? There is no loops in your code only two possible execution branches with one label. To determine stack depth correctly one has to visit both execution branches and return maximum stack effect.

Also the code that you mention isn't "regular" (we can reach L1 label with two different stack
depths), so CPython won't generate such code...

@serprex
Copy link
Owner

serprex commented Feb 21, 2016

CPython won't but a programmer may. Byteplay also supports creating constants that are mutable

Yes, there are no loops. The stack depth calculation should only throw an error if one creates a loop which makes the possible stack depth unbounded

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

No branches or pull requests

3 participants