php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80781 Error handler that throws ErrorException infinite loop
Submitted: 2021-02-22 00:58 UTC Modified: -
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dktapps at pmmp dot io Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 7.4.15 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
10 - 9 = ?
Subscribe to this entry?

 
 [2021-02-22 00:58 UTC] dktapps at pmmp dot io
Description:
------------
This bug seems to be specific to 7.4 and upwards: it doesn't reproduce on 7.3 and below, as seen here: https://3v4l.org/EpP2L

The following code results in an infinite loop on Windows and a segmentation fault on Linux.

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

declare(strict_types=1);

function handle(int $severity, string $message, string $file, int $line) : bool{
	if((error_reporting() & $severity) !== 0){
		throw new \ErrorException($message, 0, $severity, $file, $line);
	}

	return true; //stfu operator
}

set_error_handler('handle');
function getPlugin(string $plugin) : bool{
	return false;
}
$data = [];
$array = [];
if(isset($array[$data]) or getPlugin($data)){

}


Expected result:
----------------
Something like the following:

Fatal error: Uncaught ErrorException: Illegal offset type in isset or empty in /in/EpP2L:19
Stack trace:
#0 /in/EpP2L(19): handle(2, 'Illegal offset ...', '/in/EpP2L', 19, Array)
#1 {main}
  thrown in /in/EpP2L on line 19

Actual result:
--------------
An infinite loop occurs on Windows.
Judging by the exit code on 3v4l, it appears this script causes a segfault on Unix.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-22 08:38 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6dd85f83f78fbafc4a90b264e577a31b59323314
Log: Fixed bug #80781
 [2021-02-22 08:38 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC