-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
GH-115709: Invalidate executors when a local variable is changed via frame.f_locals #118639
GH-115709: Invalidate executors when a local variable is changed via frame.f_locals #118639
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this isn't incorrect I'm not super happy with the inconsistency of sometimes #ifdef
ing out the call and other times relying on the dummy version existing. But this works, so do what's expedient to make it into beta 1.
if (_PyOpcode_Caches[_PyOpcode_Deopt[opcode]]) { | ||
PAUSE_ADAPTIVE_COUNTER(this_instr[1].counter); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it connect to the purpose of the PR? Or is it just a drive-by bugfix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unconnected.
This PR uncovered the bug, so I'll need to fix it before merging this. Might as well do it here.
@@ -148,8 +148,9 @@ framelocalsproxy_setitem(PyObject *self, PyObject *key, PyObject *value) | |||
if (PyUnicode_CheckExact(key)) { | |||
int i = framelocalsproxy_getkeyindex(frame, key, false); | |||
if (i >= 0) { | |||
_PyLocals_Kind kind = _PyLocals_GetKind(co->co_localspluskinds, i); | |||
_Py_Executors_InvalidateDependency(PyInterpreterState_Get(), co, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I solved the _Py_TIER2
dependency elsewhere is to put this call itself inside #ifdef _Py_TIER2
. Then you don't need the dummy version you added to optimizer.c.
Python/optimizer.c
Outdated
#else | ||
|
||
void | ||
_Py_Executors_InvalidateDependency(PyInterpreterState *interp, void *obj, int is_invalidation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super keen on having a dummy version here -- and if we do this we should probably make a few more dummy versions and remove the occasional #if _Py_TIER2
sprinkled around elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you prefer this in optimizer.h
#else
#define _Py_Executors_InvalidateDependency(A, B, C) ((void)0)
#endif _Py_TIER2
and leave optimizer.c alone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's better. Though if this is what Brandt asks about maybe we should split it and put that bugfix in beta1 even if the f_locals bugfix goes to beta2.
Is this the same failure that we're seeing on GH-118661?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Will merge this ASAP since CI is currently broken and this fixes it.
…d via frame.f_locals (python#118639) Also fix unrelated assert in debug Tier2/JIT builds.
Skipping news as this is fixing a hypothetical bug, rather than a reported bug.
The new test causes a C assertion failure in a debug build of main.
frame.f_locals
in a debugger or similar. #115709