php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74444 multiple catch freezes in some cases
Submitted: 2017-04-14 18:07 UTC Modified: -
From: matej21 at matej21 dot cz Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.1.4 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: matej21 at matej21 dot cz
New email:
PHP Version: OS:

 

 [2017-04-14 18:07 UTC] matej21 at matej21 dot cz
Description:
------------
if there is exact number of opcodes before multi-catch, php freezes. adding or removing just one opcode fixes the issue.

relevant oplines:
 L64   #58    ECHO       ""
 L67   #59    NEW        "RuntimeException"       @0
 L67   #60    DO_FCALL
 L67   #61    THROW      @0
 L67   #62    JMP        J67
 L68   #63    CATCH      "FooEx"              $e  0
 L68   #64    JMP        J66
 L68   #65    CATCH      "RuntimeException"   $e  1
 L69   #66    ECHO       1
 L71   #67    RETURN     null                                 

Test script:
---------------
<?php


function doSth()
{
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';
	echo '';

	try {
		throw new \RuntimeException();
	} catch (\FooEx | \RuntimeException $e) {
		echo 1;
	}
}

doSth();


Expected result:
----------------
1

Actual result:
--------------
php freezes

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-14 19:19 UTC] matej21 at matej21 dot cz
php -d opcache.opt_debug_level=0x10000 output is more clear than phpdbg (in which extended value is missing)

L59:    V1 = NEW 0 string("RuntimeException")
L60:    DO_FCALL
L61:    THROW V1
L62:    JMP L67
L63:    CATCH string("FooEx") CV0($e) L0
L64:    JMP L66
L65:    CATCH string("RuntimeException") CV0($e)
L66:    ECHO int(1)
L67:    RETURN null


vs one more opcode

L60:    V1 = NEW 0 string("RuntimeException")
L61:    DO_FCALL
L62:    THROW V1
L63:    JMP L68
L64:    CATCH string("FooEx") CV0($e) L66
L65:    JMP L67
L66:    CATCH string("RuntimeException") CV0($e)
L67:    ECHO int(1)
L68:    RETURN null


see L0 vs L66


btw, it also fails when CATCH string("FooEx") CV0($e) is on line 255 or 1023
 [2017-04-14 22:28 UTC] matej21 at matej21 dot cz
I've prepared a fix https://github.com/php/php-src/pull/2481
 [2017-04-14 23:41 UTC] nikic@php.net
Automatic comment on behalf of matej21@matej21.cz
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2135b057ec33bb480a10f642a3e42ba10364b81e
Log: Fixed bug #74444: multiple catch freezes in some cases
 [2017-04-14 23:41 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC