php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68833 php --version exhausts entire memory by allocating over 2 GB
Submitted: 2015-01-15 00:59 UTC Modified: 2015-01-18 14:55 UTC
From: j dot tvr at centrum dot cz Assigned: ab (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: master-Git-2015-01-15 (snap) OS: Windows 7 x64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: j dot tvr at centrum dot cz
New email:
PHP Version: OS:

 

 [2015-01-15 00:59 UTC] 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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-15 05:38 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2015-01-15 05:38 UTC] pajoye@php.net
Please try the next snapshot, it has been fixed yesterday.
 [2015-01-18 13:10 UTC] j dot tvr at centrum dot cz
-Status: Feedback +Status: Closed
 [2015-01-18 13:10 UTC] 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-18 14:23 UTC] ab@php.net
-Assigned To: +Assigned To: ab
 [2015-01-18 14:23 UTC] 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 14:29 UTC] j dot tvr at centrum dot cz
Coreinfo output:
https://gist.github.com/JanTvrdik/0e7856da9d998ce9d244
 [2015-01-18 14:55 UTC] ab@php.net
Yeah, just to confirm - the issue was fixed here http://git.php.net/?p=php-src.git;a=commitdiff;h=8e3764e287ceb3c954dfd866dc72c9530907bef7 

Thanks :)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC