gh-104374: Remove access to class scopes for inlined comprehensions#104528
gh-104374: Remove access to class scopes for inlined comprehensions#104528JelleZijlstra merged 10 commits into
Conversation
Co-authored-by: Carl Meyer <carl@oddbird.net>
|
Found the following crash with a variation of Carl's fuzzer: This doesn't reproduce on main, so it's new from this PR. |
Sorry, something went wrong.
|
Found a different issue trying to simplify it: |
Sorry, something went wrong.
|
The problem occurs if it's a cell var in the outer comprehension and a free var in the inner one. In that case we should just do LOAD_FAST, but right now we're probably emitting _DEREF opcodes that explode because those cells don't exist in the class namespace. |
Sorry, something went wrong.
|
I pushed a fix for the above issues; it's just a matter of correcting how we decide if a comprehension is "in a class block." Looking only at |
Sorry, something went wrong.
|
Now this segfaults: Haven't tried to minimize it, but it's a compiler crash, something related to the cell/freevars: |
Sorry, something went wrong.
|
Reduced: def a():
class a:
[(lambda : b) for b in [a]]
print(b) |
Sorry, something went wrong.
|
This also reproduces on main (without this PR) and with two functions, so it's not just related to class scopes: def a():
def a():
[(lambda : b) for b in [a]]
print(b)Crashes on current main with the same backtrace as above. |
Sorry, something went wrong.
|
Thanks, I'll open a separate issue and PR for this. |
Sorry, something went wrong.
edited by bedevere-bot
LoadingUh oh!
There was an error while loading. Please reload this page.
Copy link Copy MarkdownSorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.