Bug #72257 [Fbk->Opn]: "get_defined_constants(true)" core dump
| From: | jccgls001 at 126 dot com | Date: | Mon, 23 May 2016 12:02:24 +0000 |
| Subject: | Bug #72257 [Fbk->Opn]: "get_defined_constants(true)" core dump | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-201236@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72257&edit=1
ID: 72257
User updated by: jccgls001 at 126 dot com
Reported by: jccgls001 at 126 dot com
Summary: "get_defined_constants(true)" core dump
-Status: Feedback
+Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: linux 2.6
PHP Version: 7.0.6
Block user comment: N
Private report: N
New Comment:
backtrace is here :
------------------------
Using host libthread_db library "/lib64/tls/libthread_db.so.1".
Core was generated by `install/php/bin/php -r get_defined_constants(true);'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000000302af6ff40 in strlen ()
from /home/users/lvshun_iwm/php7_odp/trunk/php/.tmp/install/php/bin/../../lib/gcc-3.4.5/libc.so.6
(gdb) bt
#0 0x000000302af6ff40 in strlen ()
from /home/users/lvshun_iwm/php7_odp/trunk/php/.tmp/install/php/bin/../../lib/gcc-3.4.5/libc.so.6
#1 0x0000000000a652b6 in zif_get_defined_constants (execute_data=0x7f9e74c120a0,
return_value=0x7f9e74c12090)
at
/home/users/lvshun_iwm/php7_odp/trunk/php/.tmp/build/php-7.0.6/Zend/zend_builtin_functions.c:2227
#2 0x0000000000ab1781 in ZEND_DO_ICALL_SPEC_HANDLER (execute_data=0x7f9e74c12030)
at /home/users/lvshun_iwm/php7_odp/trunk/php/.tmp/build/php-7.0.6/Zend/zend_vm_execute.h:586
#3 0x0000000000ab04bc in execute_ex (ex=0x7f9e74c12030)
at /home/users/lvshun_iwm/php7_odp/trunk/php/.tmp/build/php-7.0.6/Zend/zend_vm_execute.h:417
#4 0x0000000000ab0c66 in zend_execute (op_array=0x7f9e74c610e0, return_value=0x7ffffa23d620)
at /home/users/lvshun_iwm/php7_odp/trunk/php/.tmp/build/php-7.0.6/Zend/zend_vm_execute.h:458
#5 0x0000000000a18f78 in zend_eval_stringl (str=0x17d4cd0 "get_defined_constants(true);",
str_len=28, retval_ptr=0x0,
string_name=0x1353fcc "Command line code")
at /home/users/lvshun_iwm/php7_odp/trunk/php/.tmp/build/php-7.0.6/Zend/zend_execute_API.c:1135
#6 0x0000000000a19135 in zend_eval_stringl_ex (str=0x17d4cd0
"get_defined_constants(true);", str_len=28, retval_ptr=0x0,
string_name=0x1353fcc "Command line code", handle_exceptions=1)
at /home/users/lvshun_iwm/php7_odp/trunk/php/.tmp/build/php-7.0.6/Zend/zend_execute_API.c:1176
#7 0x0000000000a191ad in zend_eval_string_ex (str=0x17d4cd0
"get_defined_constants(true);", retval_ptr=0x0,
string_name=0x1353fcc "Command line code", handle_exceptions=1)
at /home/users/lvshun_iwm/php7_odp/trunk/php/.tmp/build/php-7.0.6/Zend/zend_execute_API.c:1187
#8 0x0000000000b6a05c in do_cli (argc=3, argv=0x17d4c60)
at /home/users/lvshun_iwm/php7_odp/trunk/php/.tmp/build/php-7.0.6/sapi/cli/php_cli.c:1005
#9 0x0000000000b6b0f5 in main (argc=3, argv=0x17d4c60)
at /home/users/lvshun_iwm/php7_odp/trunk/php/.tmp/build/php-7.0.6/sapi/cli/php_cli.c:1344
Previous Comments:
------------------------------------------------------------------------
[2016-05-23 10:23:55] laruence@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php
for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php
for Win32
Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
I can not reproduce this.
------------------------------------------------------------------------
[2016-05-23 07:39:24] jccgls001 at 126 dot com
Description:
------------
hi,
I find that when using "get_defined_constants()" function with args "true", zend
core will dump. the code like this :
var_dump(get_defined_constants(true));
---------------------------------------------------------
About debug detail:
I debug the code with gdb and find, this bug maybe caused by
"zend_startup_builtin_functions()" in zend_builtin_functions.c(line 362), which the code :
zend_builtin_module.module_number = 0;
this place assign module index to 0, which will cause "get_defined_constants(true)" dump.
Because in this function, the 0 index is reserved to "internal".
----------------------------------------------------------
About fix:
I think the code in zend_builtin_functions.c(line 362) can be modified to:
zend_builtin_module.module_number = zend_next_free_module();
this will lead index to 1, and can make "get_defined_constants(true)" run correctly.
Test script:
---------------
get_defined_constants(true);
Expected result:
----------------
two dimension array that contains all defined constants group by module's name
Actual result:
--------------
segmentation fault and core dump
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72257&edit=1