php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13806 zlib compression is broken?
Submitted: 2001-10-24 01:18 UTC Modified: 2001-11-11 06:16 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: yasuo_ohgaki at yahoo dot com Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 4.1.0 RC CVS-2001-11-11 OS: Linux 2.4.4/glibc 2.2.2
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: yasuo_ohgaki at yahoo dot com
New email:
PHP Version: OS:

 

 [2001-10-24 01:18 UTC] yasuo_ohgaki at yahoo dot com
It seems zlib compression is broken in 4.1.0RC.

[23-Oct-2001 20:14:19] PHP Fatal error:  Allowed memory size of 8388608 bytes exhausted at zlib.c:995 (tried to allocate 2610349 bytes) in /home/yohgaki/public_html/test/phpinfo.php on line 1

Apache 1.3.20/PHP 4.1.0RC CVS/Linux 2.4.4 glibc 2.2.2

Is this happening only to me?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-24 01:23 UTC] sniper@php.net
Could you please add a short example script here? :)

 [2001-10-24 01:35 UTC] yasuo_ohgaki at yahoo dot com
Thanks for your interest, Jani.

The script is 

<?php phpinfo(); ?>

I set zlib compression in php.ini. configure line is as follows. If you cannot reproduece this problem with your usual configure line, I'll try to reduce number of options. Let me know if you want me do that.
'./configure' \
'--with-apxs' \
'--disable-short-tags' \
'--without-mysql' \
'--with-bz2' \
'--with-curl' \
'--with-ftp' \
'--with-iconv' \
'--with-mhash' \
'--with-mcrypt' \
'--with-openssl' \
'--with-pgsql' \
'--with-regex=system' \
'--with-zlib' \
'--with-gd' \
'--enable-gd-native-ttf' \
'--with-freetype-dir=/usr/local' \
'--with-jpeg-dir=/usr' \
'--with-png-dir=/usr' \
'--with-xpm-dir=/usr/X11R6' \
'--enable-bcmath' \
'--enable-ftp' \
'--enable-shmop' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--enable-sockets' \
'--enable-mbstring' \
'--enable-mbstr-enc-trans' \
'--enable-memory-limit' \
'--enable-wddx' \
'--enable-debug' 

 [2001-10-24 03:20 UTC] sniper@php.net
I can not reproduce this. Add the relevant php.ini settings
here and try also to reduce some of the configure options.

--Jani

 [2001-10-24 08:46 UTC] yasuo_ohgaki at yahoo dot com
This is not exactly what I've reported, but if following problem is fixed, this bug may be fixed. 

Fixing this may fix bug #13698, also. (CGI version segfaults at shutdown)

php.ini:
php.ini-recommened. Only change I've made is enable ZLIB compression. If zlib compression is off, it seems working.

Script:
<?php phpinfo(); ?>

Configure:
'./configure' \
'--with-apxs' \
'--disable-short-tags' \
'--without-mysql' \
'--without-pear' \
'--with-zlib' \
'--enable-debug'

PHP:
4.1.0RC CVS (today)

Env:
Linux 2.4.4/glibc 2.2.2/zlib 1.1.3
Apache 1.3.20/modssl 2.8.4

Apache error log:
Unknown(0) : Fatal error - Maximum execution time of 30 seconds exceeded
output.c(307) :  Freeing 0x418D502C (9105409 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
zlib.c(995) :  Freeing 0x4147A02C (4565991 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
Last leak repeated 10 times
output.c(289) :  Freeing 0x081ADD4C (6144 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
zend_stack.c(45) :  Freeing 0x081AC4BC (40 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
zend_stack.c(27) :  Freeing 0x081AC38C (256 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
Last leak repeated 7 times
zend_hash.c(176) :  Freeing 0x081AC2F4 (32 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
Last leak repeated 9 times
zend_hash.c(260) :  Freeing 0x081AC244 (44 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
Last leak repeated 40 times
main.c(1159) :  Freeing 0x081AC194 (44 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
zend_API.c(561) : Actual location (location was relayed)
main.c(1158) :  Freeing 0x081AC154 (12 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
main.c(1141) :  Freeing 0x081ABC04 (44 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
zend_API.c(561) : Actual location (location was relayed)
main.c(1140) :  Freeing 0x081ABBC4 (12 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
php_variables.c(170) :  Freeing 0x081ABB24 (12 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
Last leak repeated 27 times
php_variables.c(47) :  Freeing 0x081ABAD4 (27 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
Last leak repeated 27 times
zend_hash.c(438) :  Freeing 0x081AB10C (128 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
main.c(1022) :  Freeing 0x081AA11C (44 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
zend_API.c(561) : Actual location (location was relayed)
main.c(1021) :  Freeing 0x081AA0DC (12 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
php_variables.c(229) :  Freeing 0x081AA04C (12 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
Last leak repeated 1 time
php_variables.c(230) :  Freeing 0x081A9F94 (44 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
zend_API.c(561) : Actual location (location was relayed)
Last leak repeated 1 time
output.c(325) :  Freeing 0x081A86FC (6145 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
zend_ptr_stack.c(29) :  Freeing 0x081A857C (256 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
Last leak repeated 2 times
zend_ini.c(193) :  Freeing 0x081A7744 (31 bytes), script=/home/yohgaki/public_html/test/phpinfo.php
Last leak repeated 2 times
[Wed Oct 24 19:24:43 2001] [warn] child process 4029 still did not exit, sending a SIGTERM
[Wed Oct 24 19:24:47 2001] [error] child process 4029 still did not exit, sending a SIGKILL
[Wed Oct 24 19:24:47 2001] [notice] caught SIGTERM, shutting down

 [2001-10-27 16:09 UTC] yasuo_ohgaki at yahoo dot com
This bug may be related to following bugs.

http://bugs.php.net/bug.php?id=12270
http://bugs.php.net/bug.php?id=13698
 [2001-10-27 16:24 UTC] yasuo_ohgaki at yahoo dot com
Just an update.

Better procedure to reproduce this bug. I can reproduce this bug on RedHat 7.1(kernel 2.4.7) and Kondara 2.0(Kernel 2.4.4)

I think this bug is *critical* and better to be fixed/workarounded before 4.1.0 release.... (Or disable zlib.output_compression?)

Caution: This can crash your linux kernel and may crash filesystem.

1) Get 4.1.0RC CVS source
2) Copy php.ini-recommend to php.ini and enable zlib.output_compression

zlib.output_compression=On

3) configure/build/install PHP 4.1.0RC

'./configure' \
'--with-apxs' \
'--disable-short-tags' \
'--without-mysql' \
'--without-pear' \
'--with-zlib' \
'--enable-debug'

4) Create test php script containing
<?php phpinfo(); ?>

5) restart httpd, diplay the test script

6) Stop httpd and check apache error log see if
memory leak is reported or not.


 [2001-10-28 07:29 UTC] yasuo_ohgaki at yahoo dot com
via-rihine chipset NIC dvriver seems to be fixed in 2.4.13, finanlly :) I could upgrade kernel from 2.4.4 to 2.4.14-pre3. 

It seems many *.c files are not modified for new asm/*.h files, yet. (It was the same, when I tried 2.4.13) Therefore, I couldn't use the same config as 2.4.4. I was using 2.4.4 kernel that comes with my distribution. Most of kernel drivers/options are compiled in or compiled as module. I'm using kernel optimized for my test PC now. Kernel may crash with other options/modules...

Anyway, PHP behaves much better with newer kernel. New behavior is as follows.

* PHP outputs the top part of the test script "<?php phpinfo(); ?>" correctly.
* PHP sends a lot of garbages with the test script.
* Kernel seems to stop freezing.
+ PHP stopped complaining about many memory leaks at shutdown.

Problem: 
* When memory limit is enabled, PHP do not terminate script execution even if it is already exhausted memory. (I get multiple error message for a single execution as attached apache error log)
* PHP can't send proper phpinfo() output. 
* PHP segfaults with my scripts.

I changed bug type form Zlib Related to Reproducible crash. If your PHP does not segfault easily, please let me know. I'll send back trace.

== apache error log start ==
/home/yohgaki/public_html/test/phpinfo.php(1) : Fatal error - Allowed memory size of 8388608 bytes exhausted at zlib.c:995 (tried to allocate 2915587 bytes)
/home/yohgaki/public_html/test/phpinfo.php(1) : Fatal error - Allowed memory size of 8388608 bytes exhausted at zlib.c:995 (tried to allocate 2915587 bytes)
/home/yohgaki/public_html/test/phpinfo.php(1) : Fatal error - Allowed memory size of 8388608 bytes exhausted at zlib.c:995 (tried to allocate 2915587 bytes)
/home/yohgaki/public_html/test/phpinfo.php(1) : Fatal error - Allowed memory size of 8388608 bytes exhausted at zlib.c:995 (tried to allocate 2915587 bytes)
/home/yohgaki/public_html/test/phpinfo.php(1) : Fatal error - Allowed memory size of 8388608 bytes exhausted at zlib.c:995 (tried to allocate 2915587 bytes)
/home/yohgaki/public_html/test/phpinfo.php(1) : Fatal error - Allowed memory size of 8388608 bytes exhausted at zlib.c:995 (tried to allocate 2915587 bytes)
/home/yohgaki/public_html/test/phpinfo.php(1) : Fatal error - Allowed memory size of 8388608 bytes exhausted at zlib.c:995 (tried to allocate 2915587 bytes)
/home/yohgaki/public_html/test/phpinfo.php(1) : Fatal error - Allowed memory size of 8388608 bytes exhausted at zlib.c:995 (tried to allocate 2915587 bytes)
/home/yohgaki/public_html/test/phpinfo.php(1) : Fatal error - Allowed memory size of 8388608 bytes exhausted at zlib.c:995 (tried to allocate 2915587 bytes)
/home/yohgaki/public_html/test/phpinfo.php(1) : Fatal error - Allowed memory size of 8388608 bytes exhausted at zlib.c:995 (tried to allocate 2915587 bytes)
== end ==

 [2001-10-28 08:50 UTC] yasuo_ohgaki at yahoo dot com
Upgraded from apache 1.3.20 to 1.3.22.
httpd exited with status code 01 while running under gdb.

(gdb) run -X
Starting program: /usr/sbin/httpd -X

Program exited with code 01.
(gdb) 

 [2001-10-28 10:28 UTC] yasuo_ohgaki at yahoo dot com
Problem is appearent if output is larger than output buffer size.

httpd exits with code 01 with following script 
(No output)

<?php
for ($i=0; $i < 1024; $i++) echo 'abcd';
?>

but it not with
(Output is correct)

<?php
for ($i=0; $i < 1023; $i++) echo 'abcd';
?>

It exits with code 01 with more complex script w/o output, though.
 [2001-11-10 11:07 UTC] zeev@php.net
This is most probably not a bug, at least not in the way you perceive it.  With a large output buffer - the script will indeed have to consume lots of memory.  If your memory limit does not allow this - you'll get these warnings, and in case of a debug build - those complaints about memory being freed...

Now, there could be two authentic bugs:

(a) There may be a bug in the memory limit implementation.  However, it's the same as it has been for years, and it may be that just output buffering is exploiting it in a way that wasn't thought of before.  Generally, if the memory limit is reached, PHP tries to bail out nicely.  If somehow, PHP goes on consuming more memory, beyond 1MB above the memory limit - it performs a hard exit().  It's possible that the shutdown sequence causes some loop of memory exhaustion - bailout - memory exhaustion - bailout#2 - etc., which cannot be broken.  I'll take a look at it.

(b) There might be a memory leak in the zlib output compression code.  Please let me know what buffer size you use.  You really shouldn't be using more than about 16KB or so.

 [2001-11-10 11:12 UTC] zeev@php.net
This issue does not appear to be related in any way to the bug id's 12270 and 13698...

 [2001-11-10 11:48 UTC] zeev@php.net
Looks like it may be related to bug #13698 after all.  The mbstring-auto-conversion may be the problem here, as without it - I cannot reproduce the bug, and it appears to work fine...

 [2001-11-10 19:16 UTC] yasuo_ohgaki at yahoo dot com
Thanks for your time.

However, 8MB memory limit should be enough for phpinfo() output with zlib compression, isn't it?
Buffer size is default. (4096)

I'll test against with current 4.1.0RC CVS and 4.2.0-dev and report result later.

 [2001-11-10 20:44 UTC] yasuo_ohgaki at yahoo dot com
Tested with current 4.1.0RC/4.2.0 CVS.

configure:
#! /bin/sh
#
# Created by configure

'./configure' \
'--with-apxs' \
'--disable-short-tags' \
'--without-mysql' \
'--without-pear' \
'--with-zlib' \
'--enable-debug' \
"$@"

php.ini : php.ini-recommended with zlib compression ON

test script #1 (more than buf size):
<?php

for ($i=0; $i < 1026; $i++) {
        echo "abcd";
}

?>

test script #2 (less than buf size):
?php

for ($i=0; $i < 1022; $i++) {
        echo "abcd";
}

?>


result - 4.1.0RC: 
4.1.0RC works fine without zlib compression, but not with zlib output compression. httpd just keeps growing when output exceed buf size. (I killed it when it became 100MB)

It cannot display phpinfo().
There are many log entry for memory leak for apache.
result - 4.2.0:
It seems there is no problem in 4.2.0 now. It works for both script and can display phpinfo(). (It was not working before, at least when 4.1.0RC1 is released.)

output.c has not been changed. It seems real problem was in some other place.

 [2001-11-11 06:16 UTC] yasuo_ohgaki at yahoo dot com
This bug is fixed for both 4.1.0 and 4.2.0.
Closed.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 22 19:01:23 2020 UTC