-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
gh-137838: Fix JIT trace buffer overrun by pre-reserving exit stub space #138173
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
Conversation
77e04ea to
214be19
Compare
214be19 to
0776a59
Compare
Python/optimizer.c
Outdated
| // Leave space for possible trailing _EXIT_TRACE | ||
| int max_length = buffer_size-2; | ||
| // Leave space for possible trailing _EXIT_TRACE and estimated exit stubs | ||
| // Reserve 20% of buffer space for exit stubs (empirically sufficient) |
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.
Can we have a tighter and more logical bound than this?
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.
Maybe 15%? or 10%?
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.
10% is too small. Let me test from 15%.
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.
No I mean something based on math. Like a loose bound would be:
Every instruction needs a _DEOPT or _EXIT_TRACE
_DEOPT might have _ERROR_POP_N before it
Therefore from n instructions we must reserve 2n instructions.
This bound is overly loose, but it would be good to work it out
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.
Hmm, let me think about this differently. I’ll share the next commit with an improvement that tracks each instruction based on a mathematical assumption
|
Hi @Fidget-Spinner, I adjusted the calculation of max_length to take a more conservative approach. On my local setup, both of the following tests passed:
I’m not entirely sure if this approach is ideal from the JIT maintainers’ perspective, so I’d appreciate it if you could take a look before we ask them for a review. |
…g exit stub space" This reverts commit 0776a59.
|
Hmm, not sure if this 20% magic number is the correct way.. Let me take a look other approach that calculate max_length properly. |
Uh oh!
There was an error while loading. Please reload this page.