-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
bpo-44446: set lineno in generator instructions #26782
Conversation
d078463
to
640f0a0
Compare
640f0a0
to
43df6da
Compare
When generator instructions were added to bytecode, lineno was always set to -1, instead of the line number. This patch sets the lineno, if there is one. Signed-off-by: Filipe Laíns <[email protected]>
43df6da
to
caba5a7
Compare
@markshannon I do not understand why this patch is causing the behavior that it is, I would have guessed that this is a fairly innocuous change, do you have any idea of what is happening? |
See #26781 (comment) |
Indeed, I am right, this is an ownership issue with the locals dictionary:
@markshannon, please take a look at this seems to be a regression either of PEP 626 or the latest changes in the frames/code object. I am not fully sure if you are accounting on this but I honestly don't see how we could have dropped the ownership of the locals dict when |
I think the issue might be in the new 3.11 bytecode. Before falling out to Lines 2473 to 2476 in a317778
After some digging, it seems like we are poping from an empty stack. What we end up popping in the test that triggers the assert happens to be the locals dict, which then gets decref'ed, and blows up afterwards. --- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2457,6 +2457,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
}
case TARGET(GEN_START): {
+ assert(!EMPTY());
PyObject *none = POP();
Py_DECREF(none);
if (!Py_IsNone(none)) {
I have also managed to trigger another issue. --- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -1447,6 +1447,7 @@ def test_jump_backwards_out_of_with_block(output):
async def test_jump_backwards_out_of_async_with_block(output):
output.append(1)
async with asynctracecontext(output, 2):
+ global test
output.append(3)
@jump_test(2, 5, [5])
Line 2248 in a317778
|
If you have any tips on how to use lltrace, that'd be very helpful, I haven't managed to figure that out 😅 |
Yeah, wait for #26822 to land and then just set |
This seems to be obsolete. @pablogsal Can you produce that issue with low refcounts for locals on main, or just here? |
Only here, but the changes in this PR shouldn't manifest that way, so something is clearly going on. |
Why? If you mess around with the line numbers, it hardly seems surprising that |
But what breaks I'd not Check the rest of the conversation in this issue |
If you change the line number, you are changing the instruction pointer. If the stack depth is wrong, anything can happen. |
Sorry to bother, is there any documentation on how this works? |
I'm afraid not. |
When generator instructions were added to bytecode, lineno was always set to -1,
instead of the line number. This patch sets the lineno, if there is one.
Signed-off-by: Filipe Laíns [email protected]
https://bugs.python.org/issue44446