Edit report at https://bugs.php.net/bug.php?id=72257&edit=1
ID: 72257
Updated by: bwoebi@php.net
Reported by: jccgls001 at 126 dot com
Summary: "get_defined_constants(true)" core dump
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:
The only way this code could crash is if module->name is invalid.
Try:
USE_ZEND_ALLOC=0 valgrind php -n -r "var_dump(get_define_constants(true));"
Perhaps this finds something, but locally I cannot reproduce it either.
Also, what does php -m tell you?
Previous Comments:
------------------------------------------------------------------------
[2016-05-23 12:39:02] jccgls001 at 126 dot com
Following your advise, I use php -n -r "var_dump(get_define_constants(true);" command but
segmentation fault again. the backtrace info is same as before.
I have removed all third-party extensions when build source and before run code.
------------------------------------------------------------------------
[2016-05-23 12:13:26] laruence@php.net
try again after you disable any third-part extension.
like: php -n -r "var_dump(get_define_constants(true);", then add them one by one to check
which extension cause this.
------------------------------------------------------------------------
[2016-05-23 12:02:20] jccgls001 at 126 dot com
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
------------------------------------------------------------------------
[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