php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80976 eval() with error code causes php to crash instead of throwing an exception
Submitted: 2021-04-22 09:38 UTC Modified: 2021-05-05 17:28 UTC
From: vicreal at yandex dot ru Assigned: cmb (profile)
Status: Not a bug Package: *General Issues
PHP Version: 8.0.3 OS: Debian 10.5
Private report: No CVE-ID: None
 [2021-04-22 09:38 UTC] vicreal at yandex dot ru
Description:
------------
Debian 10.5 + php-fpm 8.0.3
eval() with error code causes php to crash instead of throwing an exception

Test script:
---------------
eval('ttt();');  // Connection reset by peer => 502 Bad Gateway
echo 'OK';
exit(0);

Expected result:
----------------
Throwing an exception with message "Call to undefined function ttt()".

Actual result:
--------------
Connection reset by peer => 502 Bad Gateway.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-22 09:45 UTC] vicreal at yandex dot ru
Additional examples:
try {
    eval('ttt();');
    echo 'OK';
} catch (Error $e) {
    echo $e->getMessage();  // "Call to undefined function ttt()"
}
exit(0);

Actual result:   "Call to undefined function ttt()".
Expected result: "Call to undefined function ttt()".

try {
   eval('ttt();');
   echo 'OK';
} catch (Error $e) {
   echo $e->getMessage();
   throw $e;  // Connection reset by peer => 502 Bad Gateway
}
exit(0);

Actual result:   Connection reset by peer => 502 Bad Gateway.
Expected result: Throwing an exception with message "Call to undefined function ttt()".

Conclusion: an exception is thrown, but if it is not caught, the php process crashes.
 [2021-05-05 15:55 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-05-05 15:55 UTC] cmb@php.net
What do you mean with "crash" – a segfault?  The code is supposed
to issue a fatal error[1]; I would expect that to produce a 500
Internal Server Error, but I don't know about FPM, and your exact
setup.

[1] <https://3v4l.org/i733n>
 [2021-05-05 17:25 UTC] vicreal at yandex dot ru
> What do you mean with "crash" – a segfault?
Yes. But this is an xdebug bug, not php bug.
 [2021-05-05 17:28 UTC] cmb@php.net
-Status: Feedback +Status: Not a bug
 [2021-05-05 17:28 UTC] cmb@php.net
Ah, thanks!  Then please open a ticket at
<https://bugs.xdebug.org/> if not already done.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 12:01:29 2024 UTC