Bug #77530 [NEW]: PHP crashes when parsing `(2)::class`
From: tysonandre775 at hotmail dot com
Operating system:
PHP version: 7.3.2RC1
Package: *General Issues
Bug Type: Bug
Bug description:PHP crashes when parsing (2)::class
Description:
------------
When an expression such as (2)::class (with brackets) is parsed in
source code, PHP (debug and non-debug) crashes.
Debug builds emit this failure: "/path/to/php-src/Zend/zend_ast.h:298:
zend_ast_get_str: Assertion `zval_get_type(&(*(zv))) == 6' failed."
This may also affect stable php versions. I also saw this in a recent
PHP 7.4 build.
Non-debug builds segfault:
Program received signal SIGSEGV, Segmentation fault.
0x00000000009b5e19 in zend_get_class_fetch_type ()
(gdb) bt
#0 0x00000000009b5e19 in zend_get_class_fetch_type ()
#1 0x00000000009b62e0 in
zend_try_compile_const_expr_resolve_class_name.part ()
#2 0x00000000009bcc5a in zend_compile_class_const ()
#3 0x00000000009bd255 in zend_compile_expr ()
#4 0x00000000009be6ab in zend_compile_echo ()
#5 0x00000000009c55e8 in zend_compile_stmt ()
#6 0x00000000009c972a in zend_compile_top_stmt ()
#7 0x00000000009c977f in zend_compile_top_stmt ()
#8 0x00000000009c977f in zend_compile_top_stmt ()
#9 0x000000000099c3dd in zend_compile ()
#10 0x000000000099dfb8 in compile_string ()
#11 0x00000000009cd00b in zend_eval_stringl ()
#12 0x00000000007e6967 in readline_shell_run ()
#13 0x0000000000a822c5 in do_cli ()
#14 0x000000000045f56c in main ()
Test script:
---------------
<?php
if (false) {
echo (2)::class;
}
Expected result:
----------------
Should not segfault. Instead, it should emit a similar error to what PHP
already does in other cases
```
php > echo []::class;
Fatal error: Dynamic class names are not allowed in compile-time ::class
fetch in php shell code on line 1
```
--
Edit bug report at https://bugs.php.net/bug.php?id=77530&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77530&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77530&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77530&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77530&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77530&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77530&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77530&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77530&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77530&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77530&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77530&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77530&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77530&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77530&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77530&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77530&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77530&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77530&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77530&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77530&r=mysqlcfg
Thread (5 messages)
- tysonandre775 at hotmail dot com