Bug #72257 [NEW]: "get_defined_constants(true)" core dump

From: Date: Mon, 23 May 2016 07:39:28 +0000
Subject: Bug #72257 [NEW]: "get_defined_constants(true)" core dump
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201234@lists.php.net to get a copy of this message
From:             jccgls001 at 126 dot com
Operating system: linux 2.6
PHP version:      7.0.6
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:"get_defined_constants(true)" core dump

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 bug report at https://bugs.php.net/bug.php?id=72257&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=72257&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=72257&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=72257&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=72257&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=72257&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=72257&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=72257&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=72257&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=72257&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=72257&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=72257&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=72257&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=72257&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72257&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=72257&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=72257&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=72257&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72257&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=72257&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=72257&r=mysqlcfg



Thread (16 messages)

« previous php.bugs (#201234) next »