Bug #65665 [Opn]: Exception not properly caught when opcache enabled

2013-09-14 Thread laruence
Edit report at https://bugs.php.net/bug.php?id=65665&edit=1

 ID: 65665
 Updated by: larue...@php.net
 Reported by:ryan dot brothers at gmail dot com
 Summary:Exception not properly caught when opcache enabled
 Status: Open
 Type:   Bug
 Package:opcache
 Operating System:   Linux
 PHP Version:5.5.3
-Assigned To:
+Assigned To:dmitry
 Block user comment: N
 Private report: N

 New Comment:

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


Previous Comments:

[2013-09-14 06:58:51] krak...@php.net

Assuming we are just going to disable unsafe optimizations, PR #450 should do 
it 
???


[2013-09-14 06:50:50] krak...@php.net

Assuming


[2013-09-13 17:16:34] Danack at basereality dot com

Running with -d opcache.optimization_level=0xfffd shows the correct 
behaviour. 
That flag is the equivalent to turning on all optimizations except:

'ZEND_OPTIMIZER_PASS_2' /* Constant conversion and jumps */


[2013-09-13 15:31:05] jpa...@php.net

This is an optimizer bug.
If you run with opcache.optimization_level=0 , the bug disappears.

I guess the bug is in the optimizer pass that handles ZEND_CATCH.
PS : I reproduced with a 5.4 base.


[2013-09-13 00:15:06] 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:
---
https://bugs.php.net/bug.php?id=65665&edit=1


Bug #65665 [Opn]: Exception not properly caught when opcache enabled

2013-09-13 Thread krakjoe
Edit report at https://bugs.php.net/bug.php?id=65665&edit=1

 ID: 65665
 Updated by: krak...@php.net
 Reported by:ryan dot brothers at gmail dot com
 Summary:Exception not properly caught when opcache enabled
 Status: Open
 Type:   Bug
 Package:opcache
 Operating System:   Linux
 PHP Version:5.5.3
 Block user comment: N
 Private report: N

 New Comment:

Assuming we are just going to disable unsafe optimizations, PR #450 should do 
it 
???


Previous Comments:

[2013-09-14 06:50:50] krak...@php.net

Assuming


[2013-09-13 17:16:34] Danack at basereality dot com

Running with -d opcache.optimization_level=0xfffd shows the correct 
behaviour. 
That flag is the equivalent to turning on all optimizations except:

'ZEND_OPTIMIZER_PASS_2' /* Constant conversion and jumps */


[2013-09-13 15:31:05] jpa...@php.net

This is an optimizer bug.
If you run with opcache.optimization_level=0 , the bug disappears.

I guess the bug is in the optimizer pass that handles ZEND_CATCH.
PS : I reproduced with a 5.4 base.


[2013-09-13 00:15:06] 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:
---
https://bugs.php.net/bug.php?id=65665&edit=1


Bug #65665 [Opn]: Exception not properly caught when opcache enabled

2013-09-13 Thread krakjoe
Edit report at https://bugs.php.net/bug.php?id=65665&edit=1

 ID: 65665
 Updated by: krak...@php.net
 Reported by:ryan dot brothers at gmail dot com
 Summary:Exception not properly caught when opcache enabled
 Status: Open
 Type:   Bug
 Package:opcache
 Operating System:   Linux
 PHP Version:5.5.3
 Block user comment: N
 Private report: N

 New Comment:

Assuming


Previous Comments:

[2013-09-13 17:16:34] Danack at basereality dot com

Running with -d opcache.optimization_level=0xfffd shows the correct 
behaviour. 
That flag is the equivalent to turning on all optimizations except:

'ZEND_OPTIMIZER_PASS_2' /* Constant conversion and jumps */


[2013-09-13 15:31:05] jpa...@php.net

This is an optimizer bug.
If you run with opcache.optimization_level=0 , the bug disappears.

I guess the bug is in the optimizer pass that handles ZEND_CATCH.
PS : I reproduced with a 5.4 base.


[2013-09-13 00:15:06] 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:
---
https://bugs.php.net/bug.php?id=65665&edit=1