Commit 28b4ee1
committed
Fix inline exception handler deopt stack mismatch
The JIT's inline exception handler skips PUSH_EXC_INFO as an
optimization, but handler body bytecodes (SWAP, POP_EXCEPT) still
expect the previous exception on the stack. When the handler body
hit an unsupported opcode and deopted, the interpreter found garbage
where prev_exc should be. POP_EXCEPT then wrote garbage into
tstate->exc_info->exc_value, corrupting the exception context chain.
Fix: push Py_None as a prev_exc placeholder before handler body
bytecodes. This ensures all deopts have a valid stack layout.
Also handle SWAP inline and make POP_EXCEPT pop the placeholder.
Fixes both emitInlineExceptionMatch and emitCallExceptionHandler.1 parent d98c7f9 commit 28b4ee1
1 file changed
Lines changed: 35 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
713 | 713 | | |
714 | 714 | | |
715 | 715 | | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
716 | 729 | | |
717 | 730 | | |
718 | 731 | | |
719 | 732 | | |
720 | 733 | | |
721 | 734 | | |
722 | | - | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
723 | 741 | | |
724 | 742 | | |
725 | 743 | | |
726 | 744 | | |
727 | 745 | | |
728 | 746 | | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
729 | 751 | | |
730 | 752 | | |
731 | 753 | | |
| |||
872 | 894 | | |
873 | 895 | | |
874 | 896 | | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
875 | 903 | | |
876 | 904 | | |
877 | 905 | | |
878 | 906 | | |
879 | 907 | | |
880 | 908 | | |
| 909 | + | |
| 910 | + | |
881 | 911 | | |
882 | 912 | | |
883 | 913 | | |
884 | 914 | | |
885 | 915 | | |
886 | 916 | | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
887 | 921 | | |
888 | 922 | | |
889 | 923 | | |
| |||
0 commit comments