Bug #78489 [NEW]: "php -a" will terminate immediately for any thrown CompileError

From: Date: Wed, 04 Sep 2019 01:40:04 +0000
Subject: Bug #78489 [NEW]: "php -a" will terminate immediately for any thrown CompileError
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222545@lists.php.net to get a copy of this message
From: tandre Operating system: PHP version: 7.3.9 Package: *General Issues Bug Type: Bug Bug description:"php -a" will terminate immediately for any thrown CompileError Description: ------------ Observed: "php -a" terminates immediately when CompileError is thrown and not caught, but does not terminate for any thrown subclass (e.g. ParseError) Expected: "php -a" should report the error appropriately, but not terminate Cause: https://github.com/php/php-src/pull/2767#discussion_r320539776 // in main/main.c, we see that E_COMPILE_ERROR is treated differently from E_PARSE, and zend_ce_compile_error causes E_COMPILE_ERROR. // Changing main.c to check if E_COMPILE_ERROR is recoverable would fix the bug. case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: error_type_str = "Fatal error"; syslog_type_int = LOG_ERR; break; Test script: --------------- php > throw new ParseError('x'); Parse error: x in php shell code on line 1 php > throw new CompileError('x'); Fatal error: x in php shell code on line 1 .... This terminates php -a php > var_export(token_get_all('<?php abstract final class X{}', TOKEN_PARSE)); Fatal error: Cannot use the final modifier on an abstract class in on line 1 .... This also terminates php -a php > try {throw new CompileError('x');} catch (Throwable $_) { var_export($_); } Outputs CompileError::__set_state(array(... Expected result: ---------------- "php -a" should report the error appropriately, but not terminate Actual result: -------------- Observed: "php -a" terminates immediately when CompileError is thrown and not caught, but does not terminate for any thrown subclass (e.g. ParseError) -- Edit bug report at https://bugs.php.net/bug.php?id=78489&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78489&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78489&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78489&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78489&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78489&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78489&r=support Expected behavior: https://bugs.php.net/fix.php?id=78489&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78489&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78489&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78489&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78489&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78489&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78489&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78489&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78489&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78489&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78489&r=mysqlcfg

« previous php.bugs (#222545) next »