Bug #66608 [Opn]: Incorrect behavior with nested "finally" blocks

From: Date: Sat, 01 Feb 2014 02:44:20 +0000
Subject: Bug #66608 [Opn]: Incorrect behavior with nested "finally" blocks
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184111@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66608&edit=1

 ID:                 66608
 User updated by:    drewparoski at gmail dot com
 Reported by:        drewparoski at gmail dot com
 Summary:            Incorrect behavior with nested "finally" blocks
 Status:             Open
 Type:               Bug
-Package:            *General Issues
+Package:            Scripting Engine problem
 Operating System:   CentOS Linux 6.3
 PHP Version:        5.6.0alpha1
 Block user comment: N
 Private report:     N

 New Comment:

Changed the bug category from "General Issues" to "Scripting Engine problem".


Previous Comments:
------------------------------------------------------------------------
[2014-01-30 03:24:19] drewparoski at gmail dot com

Description:
------------
The test script I provided _should_ print out "1", "2", "3",
"4", and "5" in order and then it should exit gracefully.

When I run the test script under PHP 5.6.0alpha1 (downloaded and built today from http://downloads.php.net/tyrael/php-5.6.0alpha1.tar.gz),
it prints out "1", "2", and "3", and then it gets stuck in an infinite
loop that keeps printing out "4" over and over again. It never prints out "5"
and the php process never exits.

I can consistently reproduce this behavior on my machine. I'm running CentOS Linux 6.3 on a
64-bit Intel Xeon processor, but I think this bug should be easily reproducible on most other
platforms and processors.

I attached gdb to the php process to investigate, and it appears that the Zend engine is getting
stuck in an infinite loop that keeps jumping between in execute_ex(), ZEND_JMP_SPEC_HANDLER(),
ZEND_FAST_RET_SPEC_HANDLER(), and ZEND_ECHO_SPEC_CONST_HANDLER() from "zend_vm_execute.h".

I can also reproduce this bug with various builds of PHP 5.5.0.

Test script:
---------------
<?php
function bar() {
  try {
    echo "1\n";
  } finally {
    try {
      throw new Exception("");
    } catch (Exception $ab) {
      echo "2\n";
    } finally {
      echo "3\n";
    }
    echo "4\n";
  }
  echo "5\n";
}
bar();

Expected result:
----------------
1
2
3
4
5

Actual result:
--------------
1
2
3
4
4
4
4
4
4
4
4
... the php process keeps printing "4" over and over forever ...


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=66608&edit=1


Thread (5 messages)

« previous php.bugs (#184111) next »