|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-09-13 00:15 UTC] ryan dot brothers at gmail dot com
Description:
------------
When running the following script with opcache enabled, the exception is not caught by the correct catch block. The exception should be caught by the 'caught by 1' block, but it is instead caught by the 'caught by 2' block. Disabling opcache causes the exception to be caught in the correct block.
Run the script with:
php -n -d zend_extension=opcache.so -d opcache.enable_cli=1 script.php
Test script:
---------------
<?php
try
{
switch (1)
{
case 0:
try
{
}
catch (Exception $e)
{
}
break;
case 1:
try
{
throw new Exception('aaa');
}
catch (Exception $e)
{
echo 'caught by 1';
exit;
}
break;
}
}
catch (Exception $e)
{
echo 'caught by 2';
exit;
}
Expected result:
----------------
caught by 1
Actual result:
--------------
caught by 2
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 09:00:01 2025 UTC |
Hey: I got a different fix: $ git diff diff --git a/Optimizer/block_pass.c b/Optimizer/block_pass.c index b8c3814..fd76322 100644 --- a/Optimizer/block_pass.c +++ b/Optimizer/block_pass.c @@ -1278,8 +1278,17 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array) if (op_array->last_try_catch) { int i; for (i = 0; i< op_array->last_try_catch; i++) { - op_array->try_catch_array[i].try_op = cfg->try[i]- >start_opline - new_opcodes; - op_array->try_catch_array[i].catch_op = cfg->catch[i]- >start_opline - new_opcodes; + if (cfg->try[i]->access) { + op_array->try_catch_array[i].try_op = cfg->try[i]- >start_opline - new_opcodes; + } else { + op_array->try_catch_array[i].try_op = 0; + } + + if (cfg->catch[i]->access) { + op_array->try_catch_array[i].catch_op = cfg- >catch[i]->start_opline - new_opcodes; + } else { + op_array->try_catch_array[i].catch_op = 0; + } } efree(cfg->try); efree(cfg->catch); dmitry, could you please verify this? thanks