-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
test_sys_settrace -R 3:3 does crash #109052
Comments
Reverting the codeobject.c is enough to workaround the regression: diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 70a0c2ebd6..58306075ca 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -2145,6 +2145,7 @@ static struct PyMethodDef code_methods[] = {
{"co_positions", (PyCFunction)code_positionsiterator, METH_NOARGS},
CODE_REPLACE_METHODDEF
CODE__VARNAME_FROM_OPARG_METHODDEF
+ {"__replace__", _PyCFunction_CAST(code_replace), METH_FASTCALL|METH_KEYWORDS},
{NULL, NULL} /* sentinel */
};
With this revert:
|
I do not understand how adding an alias of an existing method, which is not even used here, can cause a crash. |
I'll take a look at it tomorrow if Mark did not come up with a quick reasoning/solution. Confirmed that the fix for #108976 does not help. |
The ultimate issue for this lives in The crash requires a specific pattern, in this case, a cache entry with the opcode field that happened to have There's an interesting test to run: import sys
code1 = compile("x is x", "example.py", "eval")
code2 = compile("x in x", "example.py", "eval")
sys._getframe().f_trace_opcodes = True
sys.settrace(lambda *args: None)
exec(code1, {"x": []})
exec(code2, {"x": []})
print(code1 == code2)
sys.settrace(None) You'll find that For now, I directly stripped the instrumentation for the opcode, which resolves the crashing issue and the case above (regression test added in I don't know the correct answer to this, are they the same? We can easily add a check for the instrumented instructions, it's not difficult, but we probably need to determine the "correct answer" for that first. |
Is it possible to compare the original bytecode on code1==code2, rather than the instrumented bytecode? I think @markshannon proposed an alternative, remove code comparison operator. I recall that i worked on that operator for a strange statement building two code objects on the same line. The regression test should be somewhere in test_compile, I suppose. |
I confirm that the bug is fixed:
|
Regression introduced by: commit 6f3c138
Linked PRs
The text was updated successfully, but these errors were encountered: