Skip to content

Fix GH-22280: Ignore non-finally try blocks#22286

Merged
TimWolla merged 3 commits into
php:PHP-8.4from
prateekbhujel:prateek/gh22280-goto-finally
Jun 14, 2026
Merged

Fix GH-22280: Ignore non-finally try blocks#22286
TimWolla merged 3 commits into
php:PHP-8.4from
prateekbhujel:prateek/gh22280-goto-finally

Conversation

@prateekbhujel

@prateekbhujel prateekbhujel commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Fixes GH-22280.

zend_check_finally_breakout() checked every try/catch table entry as if it had a finally range. For a plain try/catch, finally_op is zero, so a goto emitted at opcode 0 could be treated as leaving a fake finally block.

Skip entries without a finally_op before checking finally jump boundaries.

Tests run:

  • Manual sapi/cli/php -r reproducer before and after the fix
  • sapi/cli/php run-tests.php -q Zend/tests/try/gh22280.phpt Zend/tests/try/finally_goto_001.phpt Zend/tests/try/finally_goto_002.phpt Zend/tests/try/finally_goto_003.phpt Zend/tests/try/finally_goto_004.phpt Zend/tests/try/finally_goto_005.phpt Zend/tests/try/try_finally_005.phpt Zend/tests/try/try_finally_006.phpt Zend/tests/try/try_finally_007.phpt Zend/tests/try/try_finally_008.phpt Zend/tests/try/try_finally_009.phpt Zend/tests/jump13.phpt Zend/tests/jump17.phpt
  • sapi/cli/php run-tests.php -q Zend/tests/try Zend/tests/jump01.phpt ... Zend/tests/jump17.phpt
  • git diff --cached --check

@TimWolla TimWolla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct to me.

@TimWolla

Copy link
Copy Markdown
Member

Windows failure is unrelated.

@TimWolla TimWolla merged commit 9e9b309 into php:PHP-8.4 Jun 14, 2026
17 of 18 checks passed
TimWolla added a commit that referenced this pull request Jun 14, 2026
* PHP-8.4:
  Fix GH-22280: Ignore non-finally try blocks (#22286)
TimWolla added a commit that referenced this pull request Jun 14, 2026
* PHP-8.5:
  Fix GH-22280: Ignore non-finally try blocks (#22286)
@prateekbhujel prateekbhujel deleted the prateek/gh22280-goto-finally branch June 14, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants