Bug #68833 [Csd]: php --version exhausts entire memory by allocating over 2 GB

From: Date: Sun, 18 Jan 2015 14:55:33 +0000
Subject: Bug #68833 [Csd]: php --version exhausts entire memory by allocating over 2 GB
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190044@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68833&edit=1

 ID:                 68833
 Updated by:         ab@php.net
 Reported by:        j dot tvr at centrum dot cz
 Summary:            php --version exhausts entire memory by allocating
                     over 2 GB
 Status:             Closed
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Windows 7 x64
 PHP Version:        master-Git-2015-01-15 (snap)
 Assigned To:        ab
 Block user comment: N
 Private report:     N

 New Comment:

Yeah, just to confirm - the issue was fixed here http://git.php.net/?p=php-src.git;a=commitdiff;h=8e3764e287ceb3c954dfd866dc72c9530907bef7


Thanks :)


Previous Comments:
------------------------------------------------------------------------
[2015-01-18 14:29:06] j dot tvr at centrum dot cz

Coreinfo output:
https://gist.github.com/JanTvrdik/0e7856da9d998ce9d244

------------------------------------------------------------------------
[2015-01-18 14:23:48] ab@php.net

@j dot tvr at centrum dot cz, does your processor support the lzcnt instruction? To find out with
coreinfo.exe

Thanks.

------------------------------------------------------------------------
[2015-01-18 13:10:46] j dot tvr at centrum dot cz

I tried the new snapshot from today (6a13e1f) and the problem seems to be fixed. Thanks.

------------------------------------------------------------------------
[2015-01-15 05:38:01] pajoye@php.net

Please try the next snapshot, it has been fixed yesterday.

------------------------------------------------------------------------
[2015-01-15 00:59:06] j dot tvr at centrum dot cz

Description:
------------
PHP 7 snapshots after 2014-10-16 (i.e. the last working snapshot I have is from 2014-10-16) always
returns in "Out of memory" even for very things like php --version. It does not matter
whether it is a TS, NTS, x86 or x64. The result is always the same.

Today I tried to look into it to determine the cause. Note that I've never debugged a PHP
binary before and I may have done something entirely wrong. Here is what I have found out:

"Out of memory" is a message from https://github.com/php/php-src/blob/e9068cefb4d97483823f8ee4dc384da7adf0c124/Zend/zend_alloc.h#L173,
meaning that malloc call failed because PHP has exhausted all available memory (8 GB installed).

This is a callstack from one of the exhausting allocation call:
php7.dll!_safe_malloc(unsigned __int64 nmemb=8791237589792, unsigned __int64 size=8791237761384,
unsigned __int64 offset=2008765488)
php7.dll!_zend_hash_str_add(_HashTable * ht=0x0000000000000000, const char * str=0x0000000000000000,
unsigned __int64 len=8791237589792, _zval_struct * pData=0x0000000000000000)
php7.dll!sapi_register_post_entries(_sapi_post_entry * post_entries=0x0000000000000000)
php7.dll!php_setup_sapi_content_types()
php7.dll!sapi_startup(_sapi_module_struct * sf=0x0000000000000002)
php.exe!main(int argc=0, char * * argv=0x01d030500c41b2c3)
php.exe!__tmainCRTStartup()

Screenshot showing that php.exe --version has allocated over 2 GB:
http://screencast.com/t/AdxbuA8o6i



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=68833&edit=1


Thread (6 messages)

« previous php.bugs (#190044) next »