Uh oh!
There was an error while loading. Please reload this page.
gh-120437: Fix _CHECK_STACK_SPACE optimization problems introduced in gh-118322 - #120712
Conversation
Zheaoli
commented
Jun 18, 2024
@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! |
Fidget-Spinner
commented
Jun 19, 2024
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 |
Zheaoli
commented
Jun 19, 2024
The crash task is here It's crash in I think maybe there is a pass to specialize |
cc306fe to
c79f850CompareFidget-Spinner
commented
Jun 19, 2024
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. |
Fidget-Spinner
commented
Jun 19, 2024
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.. |
Fidget-Spinner
commented
Jun 19, 2024
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= = |
Fidget-Spinner
commented
Jun 19, 2024
What I'm trying to say is that it's likely the |
Fidget-Spinner
commented
Jun 19, 2024
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. |
Zheaoli
commented
Jun 19, 2024
Yeah! I found the same code here. |
Fidget-Spinner
commented
Jun 19, 2024
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. |
Zheaoli
commented
Jun 19, 2024
Thanks for the guide. I have noticed the reason by following the issue you reference to me. Help me a lot! |
c79f850 to
d520f93Comparec9c5064 to
dff937bCompareUh oh!
There was an error while loading. Please reload this page.
8a98321 to
55c0e85Compare_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-118322Uh oh!
There was an error while loading. Please reload this page.
_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-118322Fidget-Spinner
commented
Jun 19, 2024
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
05f2d2cCompareFidget-Spinner
commented
Jun 19, 2024
@Zheaoli please don't force-push. I will squash merge when merging so there's no need to do anything on your end :). |
Fidget-Spinner
commented
Jun 19, 2024
@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? |
Zheaoli
commented
Jun 19, 2024
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-jitand--with-pydebug(Linux) #120437