Skip to content
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-106581: Fix instrumentation in tier 2 #108493

Merged
merged 3 commits into from
Aug 25, 2023
Merged

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Aug 25, 2023

RESUME is currently written in a way that ignores changes in tracing events when running in our tier two executor. This can manifest itself as assertion errors on debug builds and missing/extra events on release builds when changing events just before an inlined call:

python: Python/instrumentation.c:1117: _Py_call_instrumentation_line: Assertion `is_version_up_to_date(code, tstate->interp)' failed.

This PR modifies RESUME to detect this condition and deoptimize back to tier one in these cases.

@brandtbucher brandtbucher added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels Aug 25, 2023
@brandtbucher brandtbucher self-assigned this Aug 25, 2023
assert(frame == tstate->current_frame);
/* Possibly combine this with eval breaker */
if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) {
int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp);
ERROR_IF(err, error);
#if TIER_ONE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd indent the #if etc. to align with the code it guards (we're using a different style here than elsewhere).

@brandtbucher brandtbucher enabled auto-merge (squash) August 25, 2023 18:43
@brandtbucher brandtbucher merged commit 4eae1e5 into python:main Aug 25, 2023
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants