-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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-120437: Fix _CHECK_STACK_SPACE
optimization problems introduced in gh-118322
#120712
Conversation
@Fidget-Spinner Thanks for the help, sir. I found the root cause and fix it. BTW I might have another question how to generate some opcode unit test to trigger the old bug so that I can confirm this issue has been solved? For now, I can only test the origin issue and confirm it. I think this is unacceptable for us. |
Please dont call me sir I'm still too young for that :). I think this looks right but I need to compare it with the old code prior to the commit. Please give me a moment. Thanks for your help! |
Do you know specifically which macro-op is affected by this? (The hint is to see where which opcode in I'm also confused by the diff. The diff uses |
The crash task is here
It's crash in I think maybe there is a pass to specialize |
cc306fe
to
c79f850
Compare
The bug is not here. It's indeed in the If you comment out this line here https://github.com/python/cpython/blob/main/Python/optimizer_bytecodes.c#L702, the code works. |
Nevermind I can't reproduce the bug anymore on my machine. Can you try my solution and report back if it passes please? |
Yep, this solution(I mean disable I'm a little confuse about the root cause.. |
Ok I recommend taking a look at Slide 17 onwards of my PyCon US 2024 presentation here https://docs.google.com/presentation/d/e/2PACX-1vTzJf_PrBzcSRtgMdbM18xXXMVjsYdJIqzNHk0WATT5ZRhjzIyGLtHCH0MXGONpcpOItjfcw63uGoFX/pub?start=false&loop=false&delayms=60000 It explains how traces work, how the optimization passes work. |
Thanks for the reference. I have tested the #116168 (the commit is 1c43468) The bug can't be reproduced in this branch. The 1ab6356 is the first commit to reproduced the code (after the 1c43468). I think I still missing something important here= = |
What I'm trying to say is that it's likely the |
Can you try removing the line at 1ab6356#diff-e5bd2b14b0b10f0f47786e26306d689ed1361c3dc3b11dcc3ea52b8a2422ff64R637 and tell me if it fixes the bug? |
After dive deeper, I think the root cause is here https://github.com/python/cpython/pull/118322/files#diff-e5bd2b14b0b10f0f47786e26306d689ed1361c3dc3b11dcc3ea52b8a2422ff64R637. I belive it will broken the trace pass. |
Yeah! I found the same code here. |
The TLDR of why it breaks can be understood by reading https://github.com/python/cpython/blob/main/Python/optimizer_analysis.c#L471. Long story short, at the end of the trace optimization pass, it merges _CHECK_STACK_SPACE to _CHECK_STACK_SPACE_OPERAND. The code breaks this by removing the link to the first _CHECK_STACK_SPACE, so what happens is the first _CHECK_STACK_SPACE_OPERAND doesn't actually check for enough space. |
Thanks for the guide. I have noticed the reason by following the issue you reference to me. Help me a lot! |
c79f850
to
d520f93
Compare
c9c5064
to
dff937b
Compare
Misc/NEWS.d/next/Core and Builtins/2024-06-19-01-58-54.gh-issue-120437.nCkIoI.rst
Outdated
Show resolved
Hide resolved
8a98321
to
55c0e85
Compare
_CHECK_STACK_SPACE
optimization problems after introduced in gh-118322
_CHECK_STACK_SPACE
optimization problems after introduced in gh-118322_CHECK_STACK_SPACE
optimization problems after introduced in gh-118322
Misc/NEWS.d/next/Core and Builtins/2024-06-19-01-58-54.gh-issue-120437.nCkIoI.rst
Outdated
Show resolved
Hide resolved
_CHECK_STACK_SPACE
optimization problems after introduced in gh-118322_CHECK_STACK_SPACE
optimization problems introduced in gh-118322
_CHECK_STACK_SPACE
optimization problems introduced in gh-118322_CHECK_STACK_SPACE
optimization problems introduced in gh-118322
In the future, please help me label the title with issue |
… introduced in pythongh-118322 Co-Authored-By: Ken Jin <kenjin@python.org> Signed-off-by: Manjusaka <me@manjusaka.me>
…e-120437.nCkIoI.rst
ce4e96e
to
05f2d2c
Compare
@Zheaoli please don't force-push. I will squash merge when merging so there's no need to do anything on your end :). |
@Zheaoli your fix seemingly fixes the 4 consistently failing Aarch64 JIT tests. Wow that's awesome! |
Thanks @Zheaoli for the PR, and @Fidget-Spinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @Zheaoli and @Fidget-Spinner, I could not cleanly backport this to
|
@Zheaoli could you please create a backport PR targetting 3.13 for this? |
Sure! |
GH-120747 is a backport of this pull request to the 3.13 branch. |
…duced in pythongh-118322 (pythonGH-120712) Co-authored-by: Ken Jin <kenjin4096@gmail.com>
…duced in pythongh-118322 (pythonGH-120712) Co-authored-by: Ken Jin <kenjin4096@gmail.com>
…duced in pythongh-118322 (pythonGH-120712) Co-authored-by: Ken Jin <kenjin4096@gmail.com>
--enable-experimental-jit
and--with-pydebug
(Linux) #120437