php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40701 Bug in Windows
Submitted: 2007-03-03 02:37 UTC Modified: 2007-04-25 19:56 UTC
Votes:5
Avg. Score:3.8 ± 1.6
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:2 (50.0%)
From: michaeldaly at magma dot ca Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 5.2.2 OS: Win XP Pro
Private report: No CVE-ID:
 [2007-03-03 02:37 UTC] michaeldaly at magma dot ca
Description:
------------
PHP 5.2.2-dev (2007-02-28-1530 snap) Apache 2.2.4 Mediawiki 1.9.2 MySQL 5.0.27.  XP Pro SP2+all current updates.

After editing about 15-20 pages in my Wiki, PHP eventually generates an error:
PHP Fatal error:  Out of memory (allocated 8388608) (tried to allocate 393216 bytes)

The error occurs in several php programs, though MessagesEn.php is the most common.  The amount of memory allocated or attempted to allocate varies.

PHP.ini currently has:
max_execution_time = 30
max_input_time = 60	
memory_limit = 512M

Computer has 2GB RAM and is not near its limit in paging etc.

It sounds similar to a bug that was reported as fixed in 5.2.0.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-03 15:50 UTC] iliaa@php.net
Based on the error it would seem that the limit is 8 megs not 512 as 
your config suggests. I suspect your configuration file is being 
ignored.
 [2007-03-03 17:18 UTC] michaeldaly at magma dot ca
PHP responds to other parameters in the PHP.ini file (e.g. display_errors = Off/On) so it is being found and used.

As I stated in my report "The amount of memory allocated or attempted to allocate varies.".  I wasn't clear - I have seen this bug occur with allocated reported at just over 1MB to just over 8MB and more often at lower levels - the specific, most recent, error message I showed is one of the larger values I've seen.

Please reconsider this bug.
 [2007-03-04 01:31 UTC] michaeldaly at magma dot ca
Further note on memory allocations:  here are the three latest failures and the programs in which they occured; the top one being the most recent and the bottom the oldest.

(allocated 1835008) (tried to allocate 98304 bytes) Parser.php
(allocated 2883584) (tried to allocate 24576 bytes) Language.php
(allocated 7340032) (tried to allocate 1572864 bytes) MessagesEn.php
 [2007-03-04 17:23 UTC] iliaa@php.net
What memory limit value phpinfo() show? 
 [2007-03-04 17:40 UTC] michaeldaly at magma dot ca
phpinfo shows memory_limit 512M.

BTW this coincides with an Apache error of:
Parent: child process exited with status 3221225477 -- Restarting.
And -access violation (hex of 3221225477 is 0xC0000005) according to a post on a web site I found.

This error with php apparently has a long history and comes and goes by mixing and matching different versions of Apache and PHP.  I don't know if this adds any useful information, but it sounds like one of those nasty problems that is hard to debug and fix.
 [2007-03-04 20:21 UTC] michaeldaly at magma dot ca
Additional thought - may be unrelated.

On my old server (Apache 1.6.3, PHP 5.0) I never saw this problem but had another, possibly related.

There was a frequent bug that I fixed with Win32DisableAcceptEx in httpd.conf.  This then introduced a memory allocation bug in Apache.  Apparently, that situation was relatively common on Windows machines with not a lot of RAM - mine was 512MB.

With current server, I have 2GB Ram and the Apache allocation bug hasn't shown up.  However, now PHP has allocation errors.  Is it possible one was "hiding" the other?  Is it possible the two situations are related?

I only mention this in the hope it might twig one of you PHP wizards.
 [2007-03-05 10:02 UTC] tony2001@php.net
Make sure you didn't set the memory limit in any other way (windows registry, httpd.conf, htaccess etc.).
If PHP says your limit is set to 8Mb, I see no reason why I shouldn't trust PHP.
 [2007-03-06 18:02 UTC] michaeldaly at magma dot ca
I can find no other mechanism for setting a memory limit.

PHP does _not_ report 8MB - it reports 512MB as per the php.ini setting.  This is reported in phpinfo.php.

This allocation error is occurring at many different allocation levels.  For example, the following occurred yesterday.  The first column is the allocated amount, the second is the amount attempted and the third is the number of times it occurred.

Allocated   Add    Freq
1048576      6144  1
1835008     98304  2
2359296     98304  2
2883584     24576  3
3407872     24576  2
3670016     24576  2
4456448      6144  1
5242880    393216  1
5505024     98304  1
5767168   1572864  3
5767168     98304  1
6029312    393216  1
6291456   1572864  2
6291456     98304  1
6553600   1572864  1
6553600     24576  1
6553600    393216  8
6815744    393216  4
7077888   1572864 11
7340032   1572864  5
7602176   1572864  1
7602176    393216  1
 786432     24576  4
 786432      6144  3
9175040   1572864  2

All these values are well below the 512MB limit.
 [2007-03-06 18:10 UTC] tony2001@php.net
Cannot reproduce anything like that.
 [2007-03-06 20:54 UTC] michaeldaly at magma dot ca
Is there a way for me to capture some kind of debug information that can help you?  I downloaded the debug files along with the latest snap and they were just PDB files and I don't know what to do with them.
 [2007-03-07 09:13 UTC] tony2001@php.net
>PHP does _not_ report 8MB - it reports 512MB as per the php.ini setting.
It _does_ report 8Mb - "PHP Fatal error:  Out of memory (allocated 8388608) (tried to allocate 393216 bytes)".

>This is reported in phpinfo.php.
memory_limit can be changed per-virtualhost, per-directory and per-script.
Therefore phpinfo() might show you 512Mb, but the real script might use different value.

>Is there a way for me to capture some kind of debug information 
>that can help you? 
Yes, please search for "memory_limit" in your scripts,.htacess and httpd.conf.
 [2007-03-07 16:04 UTC] michaeldaly at magma dot ca
> It _does_ report 8Mb - "PHP Fatal error:  Out of memory (allocated
> 8388608) (tried to allocate 393216 bytes)".

It also reports from 786KB to 9.2MB, so it appears that if the problem is a limit set externally, that limit is floating dynamically.

> Yes, please search for "memory_limit" in your scripts,.htacess
> and httpd.conf.

I searched for "memory" in the entire Apache directory tree and found nothing that resembles a limit.  I looked through httpd.conf and httpd_vhosts.conf visually and can find nothing else that looks like a memory restriction.  The only limit I can find is in PHP.ini.
 [2007-03-12 03:40 UTC] edink@php.net
Just out of the curiousity: what happens when you disable memory limit altogether?

memory_limit=-1
 [2007-03-13 04:55 UTC] michaeldaly at magma dot ca
With memory_limit = -1 there is no change.
 [2007-03-14 11:31 UTC] edink@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

A fix for memory manager was applied to CVS recently, it might solve this issue.
 [2007-03-16 16:49 UTC] michaeldaly at magma dot ca
That version has no effect.  However, I'm not so sure it's any different than the version I started with - Feb 28 build that included the early Feb memory fix.
 [2007-03-21 15:55 UTC] edwin at aucs dot org
I think I am getting the same problem with php5.2-win32-200703210430.zip

I am getting "PHP Fatal error:  Out of memory (allocated <random size>) (tried to allocate <random size> bytes)" after the server started for a while.

May be this is something related to memory leakage with mysql, as in Listing 7 of http://www.ibm.com/developerworks/opensource/library/os-php-v521/ ?
 [2007-03-25 20:19 UTC] michaeldaly at magma dot ca
While testing a new php program, I inadvertently coded an infinite loop.  While running it, the thing failed at over 400MB with an allocation error.  

This shows the config is capable of using lots of memory and the repeated failures at 0.7MB to 9MB seem anomalous.
 [2007-03-27 22:35 UTC] priyadi at priyadi dot net
this occurs to me too with PHP 5.2.1 and mediawiki 1.9.3. in my 
case, the error message stays constant: "Fatal error: Out of memory 
(allocated 5242880) (tried to allocate 1245184 bytes) in 
*****/web/languages/messages/MessagesEn.php on line 2106.

this is on RHEL 3. memory_limit is set to 128M and PHP is using CGI 
API, so I don't think this problem is related to apache.

this works in my development machine though (gentoo, same PHP 
version running as apache module).
 [2007-03-27 23:07 UTC] priyadi at priyadi dot net
I think I found the culprit. In my case it is my ulimits. my 
previous ulimits were (taken from 'ulimit -a'):

core file size (blocks, -c) 0
data seg size (kbytes, -d) 20480
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) 4
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) 10240
cpu time (seconds, -t) 60
max user processes (-u) 20
virtual memory (kbytes, -v) 20480

now they are:

core file size (blocks, -c) 0
data seg size (kbytes, -d) 204800
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) 4
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) 10240
cpu time (seconds, -t) 600
max user processes (-u) 200
virtual memory (kbytes, -v) 204800

so, my case is probably not related to this bug, sorry.
 [2007-03-28 08:41 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2007-04-05 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-04-10 18:06 UTC] michaeldaly at magma dot ca
Two snaps have been applied since the last suggestion with no chnage - the problem still occurs.
 [2007-04-10 18:19 UTC] tony2001@php.net
We still have no idea on how to reproduce it.
 [2007-04-18 00:06 UTC] ahmat at quicknet dot nl
Same error for me :( I have tried several memory_limit values but it doesn't help me to fix this issue.. Im using latest version of php with apache 2.2.. it was fine with apache 1.x
 [2007-04-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-04-25 19:56 UTC] michaeldaly at magma dot ca
I did some more searching in bugzilla for Apache bugs and stumbled across the problem.

If you set Win32DisableAcceptEx in httpd.conf, it causes a memory leak.  The Apache folk say it's a leak in Windows.  The end result is that memory is eaten up and the likely candidate for generating the final failure is PHP, since it runs most frequently on the web server and attempts to use the last little bit of memory.

Turning off Win32DisableAcceptEx avoids the memory leak, but brings in another error - winnt_accept: Asynchronous AcceptEx failed. 

Since no one wants to take charge of the problem in Windows, you have to choose which error you can live with.  It appears that the AcceptEx failure is less of a problem for me.

As a friend said - it sounds like a virus.  Yes, I responded, a virus called Windows.

Sorry for the trouble and thanks for attempts to help.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 10:03:03 2014 UTC