Bug #66608 [Ver->Csd]: Incorrect behavior with nested "finally" blocks

From: Date: Fri, 18 Jul 2014 07:51:36 +0000
Subject: Bug #66608 [Ver->Csd]: Incorrect behavior with nested "finally" blocks
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186718@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
 Updated by:         laruence@php.net
 Reported by:        drewparoski at gmail dot com
 Summary:            Incorrect behavior with nested "finally" blocks
-Status:             Verified
+Status:             Closed
 Type:               Bug
 Package:            Scripting Engine problem
 PHP Version:        5.5.8
 Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=de433d4c4756e18515e4b394298f9e3e60009692
Log: Fixed bug #66608 (Incorrect behavior with nested "finally" blocks)


Previous Comments:
------------------------------------------------------------------------
[2014-02-04 01:37:48] drewparoski at gmail dot com

Verified this happens on PHP 5.5.8, which is the current official release. Updated the version
number for this bug accordingly, though it's worth noting this bug still happens on PHP
5.6.0alpha1 as well.

------------------------------------------------------------------------
[2014-02-01 02:44:20] drewparoski at gmail dot com

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

------------------------------------------------------------------------
[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 (#186718) next »