php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69832 Assertion failed in zend_compile_const_expr_magic_const
Submitted: 2015-06-15 00:23 UTC Modified: 2015-06-15 05:08 UTC
From: bugs dot php dot net at majkl578 dot cz Assigned: nikic (profile)
Status: Closed Package: Reproducible crash
PHP Version: 7.0Git-2015-06-15 (Git) OS: Linux x86_64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bugs dot php dot net at majkl578 dot cz
New email:
PHP Version: OS:

 

 [2015-06-15 00:23 UTC] bugs dot php dot net at majkl578 dot cz
Description:
------------
PHP built from 6cb7b48846d129f088b50c4a8c4b00b7dc886f5c in DEBUG mode.

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

class Test
{
	public static $foo = [
		self::A => 'foo',
		self::B => [__CLASS__, 'foo'],
	];
}

Expected result:
----------------
No crash.

Actual result:
--------------
Crash, assertion failed:
php: /build/php/php-src/Zend/zend_compile.c:6743: void zend_compile_const_expr_magic_const(zend_ast **): Assertion `ast->attr == 373 && (compiler_globals.active_class_entry) && ((compiler_globals.active_class_entry)->ce_flags & 0x80) != 0' failed.

Backtrace:
Program received signal SIGABRT, Aborted.
0x00007ffff0906107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56	../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
#0  0x00007ffff0906107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff09074e8 in __GI_abort () at abort.c:89
#2  0x00007ffff08ff226 in __assert_fail_base (fmt=0x7ffff0a35948 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x124ec2b "ast->attr == 373 && (compiler_globals.active_class_entry) && ((compiler_globals.active_class_entry)->ce_flags & 0x80) != 0", 
    file=file@entry=0x124d4e9 "/build/php/php-src/Zend/zend_compile.c", line=line@entry=6743, function=function@entry=0x124ed5b "void zend_compile_const_expr_magic_const(zend_ast **)") at assert.c:92
#3  0x00007ffff08ff2d2 in __GI___assert_fail (assertion=0x124ec2b "ast->attr == 373 && (compiler_globals.active_class_entry) && ((compiler_globals.active_class_entry)->ce_flags & 0x80) != 0", 
    file=0x124d4e9 "/build/php/php-src/Zend/zend_compile.c", line=6743, function=0x124ed5b "void zend_compile_const_expr_magic_const(zend_ast **)") at assert.c:101
#4  0x0000000000be02f3 in zend_compile_const_expr_magic_const (ast_ptr=0x7fffeb2781a8) at Zend/zend_compile.c:6741
#5  0x0000000000be040c in zend_compile_const_expr (ast_ptr=0x7fffeb2781a8) at Zend/zend_compile.c:6775
#6  0x0000000000c50379 in zend_ast_apply (ast=0x7fffeb2781a0, fn=0xbe0340 <zend_compile_const_expr>) at Zend/zend_ast.c:514
#7  0x0000000000be0421 in zend_compile_const_expr (ast_ptr=0x7fffeb2781c8) at Zend/zend_compile.c:6778
#8  0x0000000000c50325 in zend_ast_apply (ast=0x7fffeb2781b8, fn=0xbe0340 <zend_compile_const_expr>) at Zend/zend_ast.c:509
#9  0x0000000000be0421 in zend_compile_const_expr (ast_ptr=0x7fffeb278220) at Zend/zend_compile.c:6778
#10 0x0000000000c50379 in zend_ast_apply (ast=0x7fffeb278218, fn=0xbe0340 <zend_compile_const_expr>) at Zend/zend_ast.c:514
#11 0x0000000000be0421 in zend_compile_const_expr (ast_ptr=0x7fffeb278138) at Zend/zend_compile.c:6778
#12 0x0000000000c50325 in zend_ast_apply (ast=0x7fffeb278120, fn=0xbe0340 <zend_compile_const_expr>) at Zend/zend_ast.c:509
#13 0x0000000000be0421 in zend_compile_const_expr (ast_ptr=0x7fffffff9d40) at Zend/zend_compile.c:6778
#14 0x0000000000bd44ed in zend_const_expr_to_zval (result=0x7fffffff9d70, ast=0x7fffeb278120) at Zend/zend_compile.c:6788
#15 0x0000000000bd99b2 in zend_compile_prop_decl (ast=0x7fffeb278248) at Zend/zend_compile.c:4762
#16 0x0000000000bd5671 in zend_compile_stmt (ast=0x7fffeb278248) at Zend/zend_compile.c:6899
#17 0x0000000000bd77a3 in zend_compile_stmt_list (ast=0x7fffeb278060) at Zend/zend_compile.c:4195
#18 0x0000000000bd5563 in zend_compile_stmt (ast=0x7fffeb278060) at Zend/zend_compile.c:6840
#19 0x0000000000bd3d23 in zend_compile_class_decl (ast=0x7fffeb278278) at Zend/zend_compile.c:5106
#20 0x0000000000bd569b in zend_compile_stmt (ast=0x7fffeb278278) at Zend/zend_compile.c:6908
#21 0x0000000000bdb807 in zend_compile_top_stmt (ast=0x7fffeb278278) at Zend/zend_compile.c:6818
#22 0x0000000000bdb7e9 in zend_compile_top_stmt (ast=0x7fffeb278018) at Zend/zend_compile.c:6813
#23 0x0000000000ba0992 in compile_file (file_handle=0x7fffffffdfa8, type=8) at Zend/zend_language_scanner.l:607
#24 0x00000000008b4a12 in phar_compile_file (file_handle=0x7fffffffdfa8, type=8) at ext/phar/phar.c:3310
#25 0x0000000000c04420 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at Zend/zend.c:1383
#26 0x0000000000b5a052 in php_execute_script (primary_file=0x7fffffffdfa8) at main/main.c:2475
#27 0x0000000000cf6f3a in do_cli (argc=2, argv=0x15fad80) at sapi/cli/php_cli.c:967
#28 0x0000000000cf5e3a in main (argc=2, argv=0x15fad80) at sapi/cli/php_cli.c:1334

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-15 05:00 UTC] laruence@php.net
-Assigned To: +Assigned To: nikic
 [2015-06-15 05:08 UTC] laruence@php.net
seems simply remove the trait assertion fix it..
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 6164242..be89550 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -6737,10 +6737,7 @@ void zend_compile_const_expr_magic_const(zend_ast **ast_ptr) /* {{{ */
 {
 	zend_ast *ast = *ast_ptr;

-	/* Other cases already resolved by constant folding */
-	ZEND_ASSERT(ast->attr == T_CLASS_C &&
-	            CG(active_class_entry) &&
-	            (CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) != 0);
+	ZEND_ASSERT(ast->attr == T_CLASS_C && CG(active_class_entry));

 	{
 		zval const_zv;
 [2015-06-15 15:43 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9db81340bab6e30b4b67126b500a042d61682c9d
Log: Fix bug #69832 (Assertion failure)
 [2015-06-15 15:43 UTC] bwoebi@php.net
-Status: Assigned +Status: Closed
 [2015-06-23 18:04 UTC] ab@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9db81340bab6e30b4b67126b500a042d61682c9d
Log: Fix bug #69832 (Assertion failure)
 [2016-07-20 11:38 UTC] davey@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9db81340bab6e30b4b67126b500a042d61682c9d
Log: Fix bug #69832 (Assertion failure)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 09:01:29 2024 UTC