bpo-44446: set lineno in generator instructions#26782
Conversation
d078463 to
640f0a0
Compare
June 18, 2021 00:51
640f0a0 to
43df6da
Compare
June 18, 2021 01:13
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 <lains@riseup.net>
43df6da to
caba5a7
Compare
June 18, 2021 02:38
|
@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? |
Sorry, something went wrong.
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 |
Sorry, something went wrong.
|
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 |
Sorry, something went wrong.
|
If you have any tips on how to use lltrace, that'd be very helpful, I haven't managed to figure that out 😅 |
Sorry, something went wrong.
Yeah, wait for #26822 to land and then just set |
Sorry, something went wrong.
|
This seems to be obsolete. @pablogsal Can you produce that issue with low refcounts for locals on main, or just here? |
Sorry, something went wrong.
Only here, but the changes in this PR shouldn't manifest that way, so something is clearly going on. |
Sorry, something went wrong.
Why? If you mess around with the line numbers, it hardly seems surprising that |
Sorry, something went wrong.
But what breaks I'd not Check the rest of the conversation in this issue |
Sorry, something went wrong.
|
If you change the line number, you are changing the instruction pointer. If the stack depth is wrong, anything can happen. |
Sorry, something went wrong.
|
Sorry to bother, is there any documentation on how this works? |
Sorry, something went wrong.
|
I'm afraid not. |
Sorry, something went wrong.
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 lains@riseup.net
https://bugs.python.org/issue44446