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

Counter for JUMP_BACKWARD is initialized to 17 instead of 0 #108488

Closed
gvanrossum opened this issue Aug 25, 2023 · 0 comments · Fixed by #108591
Closed

Counter for JUMP_BACKWARD is initialized to 17 instead of 0 #108488

gvanrossum opened this issue Aug 25, 2023 · 0 comments · Fixed by #108591
Assignees
Labels
type-bug An unexpected behavior, bug, or error

Comments

@gvanrossum
Copy link
Member

gvanrossum commented Aug 25, 2023

Bug report

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Output from running 'python -VV' on the command line:

Python 3.13.0a0 (heads/main-dirty:5a25daa512, Aug 25 2023, 21:20:04) [Clang 14.0.3 (clang-1403.0.22.14.1)]

A clear and concise description of the bug:

From #108311 (comment):

FWIW I also discovered that the JUMP_BACKWARD counter is initialized to 17 (the constant computed by adaptive_counter_warmup()), like all other counters, by _PyCode_Quicken() in specialize.c. Arguably, since this counter is supposed to count upwards from zero (in steps of 16, i.e. 1 << OPTIMIZER_BITS_IN_COUNTER), it ought to be initialized to zero (as I had expected it would be). But this ought to be a separate issue and PR.

Linked PRs

@gvanrossum gvanrossum added the type-bug An unexpected behavior, bug, or error label Aug 25, 2023
gvanrossum added a commit that referenced this issue Aug 29, 2023
This mis-initialization caused the executor optimization to kick in sooner than intended. It also set the lower 4 bits of the counter to `1` -- those bits are supposed to be reserved (the actual counter is in the upper 12 bits).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants