php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34038 ZLIB and output from __destruct() invalidates entire output
Submitted: 2005-08-08 16:38 UTC Modified: 2005-08-09 15:43 UTC
From: richard dot quadling at bandvulc dot co dot uk Assigned:
Status: Closed Package: Zlib related
PHP Version: 5.0.4 OS: Windows XP SP2
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: richard dot quadling at bandvulc dot co dot uk
New email:
PHP Version: OS:

 

 [2005-08-08 16:38 UTC] richard dot quadling at bandvulc dot co dot uk
Description:
------------
I have classes which do a var_dump as part of the __destruct() method if the code is running from a the development domain (all the sites are on the same server, live and development).

I recently turned on the zlib.output_compression in my php-isapi.ini file.

This has been great for the live domains, but the development domains generate no output.

If I toggle this setting and restart the webserver service (I am using Sambar Server), then I get all the output I ask for.

The "Reproduce code" below proves my point.

It seems that the output stream is closed BEFORE the destruct() methods are called, OR the destruct() methods generate output that bypassing the zlib compression in some way.

I have also included the network trace logs relevant to the requests from Sambar Server.

Sambar is not set to compress its output.




Reproduce code:
---------------
<?php
class MakeCommentWhenBeingDestroyed
	{
	private $bShowDestructionNotice = False;

	public function __construct($bShowDestructionNotice = False)
		{
		$this->bShowDestructionNotice = $bShowDestructionNotice;
		}

	public function __destruct()
		{
		if ($this->bShowDestructionNotice === True)
			{
			echo "We are being destroyed!";
			}
		}
	}

$objMCWBD = new MakeCommentWhenBeingDestroyed(True);
echo 'Object created as <pre>' . var_export($objMCWBD, True) . '</pre>' . date('r');
?>

Expected result:
----------------
Object created as 
class MakeCommentWhenBeingDestroyed {
  private $bShowDestructionNotice = true;
}
Mon, 08 Aug 2005 14:50:29 +0100We are being destroyed!

Valid tracelog from Sambar Server.
[2005-08-08 14:50:29] TCP ACCEPT [80] -> 127.0.0.1:6588
[2005-08-08 14:50:29] TCP READWAIT [80] -> 127.0.0.1:6588
[2005-08-08 14:50:29] TCP READ [80] -> 127.0.0.1:6588 [330 bytes]
000000:  47 45 54 20 2F 54 65 73 : 74 25 32 30 7A 6C 69 62   GET /Test%20zlib
000010:  25 32 30 64 65 73 74 72 : 6F 79 2E 70 68 70 20 48   %20destroy.php H
000020:  54 54 50 2F 31 2E 31 0D : 0A 41 63 63 65 70 74 3A   TTP/1.1..Accept:
000030:  20 2A 2F 2A 0D 0A 52 65 : 66 65 72 65 72 3A 20 68    */*..Referer: h
000040:  74 74 70 3A 2F 2F 6C 6F : 63 61 6C 2E 71 75 69 63   ttp://local.quic
000050:  6B 73 63 72 69 70 74 73 : 2F 0D 0A 41 63 63 65 70   kscripts/..Accep
000060:  74 2D 4C 61 6E 67 75 61 : 67 65 3A 20 65 6E 2D 67   t-Language: en-g
000070:  62 0D 0A 41 63 63 65 70 : 74 2D 45 6E 63 6F 64 69   b..Accept-Encodi
000080:  6E 67 3A 20 67 7A 69 70 : 2C 20 64 65 66 6C 61 74   ng: gzip, deflat
000090:  65 0D 0A 55 73 65 72 2D : 41 67 65 6E 74 3A 20 4D   e..User-Agent: M
0000A0:  6F 7A 69 6C 6C 61 2F 34 : 2E 30 20 28 63 6F 6D 70   ozilla/4.0 (comp
0000B0:  61 74 69 62 6C 65 3B 20 : 4D 53 49 45 20 36 2E 30   atible; MSIE 6.0
0000C0:  3B 20 57 69 6E 64 6F 77 : 73 20 4E 54 20 35 2E 31   ; Windows NT 5.1
0000D0:  3B 20 53 56 31 3B 20 2E : 4E 45 54 20 43 4C 52 20   ; SV1; .NET CLR 
0000E0:  31 2E 31 2E 34 33 32 32 : 29 0D 0A 48 6F 73 74 3A   1.1.4322)..Host:
0000F0:  20 6C 6F 63 61 6C 2E 71 : 75 69 63 6B 73 63 72 69    local.quickscri
000100:  70 74 73 0D 0A 43 6F 6E : 6E 65 63 74 69 6F 6E 3A   pts..Connection:
000110:  20 4B 65 65 70 2D 41 6C : 69 76 65 0D 0A 43 61 63    Keep-Alive..Cac
000120:  68 65 2D 43 6F 6E 74 72 : 6F 6C 3A 20 6E 6F 2D 63   he-Control: no-c
000130:  61 63 68 65 0D 0A 43 6F : 6F 6B 69 65 3A 20 52 43   ache..Cookie: RC
000140:  73 6C 62 3D 31 39 0D 0A : 0D 0A                     slb=19..........
[2005-08-08 14:50:29] TCP WRITE [80] -> 127.0.0.1:6588 [122 bytes]
000000:  48 54 54 50 2F 31 2E 31 : 20 32 30 30 20 4F 4B 0D   HTTP/1.1 200 OK.
000010:  0A 44 61 74 65 3A 20 4D : 6F 6E 2C 20 30 38 20 41   .Date: Mon, 08 A
000020:  75 67 20 32 30 30 35 20 : 31 33 3A 35 30 3A 32 39   ug 2005 13:50:29
000030:  20 47 4D 54 0D 0A 53 65 : 72 76 65 72 3A 20 53 41    GMT..Server: SA
000040:  4D 42 41 52 0D 0A 43 6F : 6E 74 65 6E 74 2D 74 79   MBAR..Content-ty
000050:  70 65 3A 20 74 65 78 74 : 2F 68 74 6D 6C 0D 0A 58   pe: text/html..X
000060:  2D 50 6F 77 65 72 65 64 : 2D 42 79 3A 20 50 48 50   -Powered-By: PHP
000070:  2F 35 2E 30 2E 34 0D 0A : 0D 0A                     /5.0.4..........
[2005-08-08 14:50:29] TCP WRITE [80] -> 127.0.0.1:6588 [141 bytes]
000000:  4F 62 6A 65 63 74 20 63 : 72 65 61 74 65 64 20 61   Object created a
000010:  73 20 3C 70 72 65 3E 63 : 6C 61 73 73 20 4D 61 6B   s <pre>class Mak
000020:  65 43 6F 6D 6D 65 6E 74 : 57 68 65 6E 42 65 69 6E   eCommentWhenBein
000030:  67 44 65 73 74 72 6F 79 : 65 64 20 7B 0A 20 20 70   gDestroyed {.  p
000040:  72 69 76 61 74 65 20 24 : 62 53 68 6F 77 44 65 73   rivate $bShowDes
000050:  74 72 75 63 74 69 6F 6E : 4E 6F 74 69 63 65 20 3D   tructionNotice =
000060:  20 74 72 75 65 3B 0A 7D : 3C 2F 70 72 65 3E 4D 6F    true;.}</pre>Mo
000070:  6E 2C 20 30 38 20 41 75 : 67 20 32 30 30 35 20 31   n, 08 Aug 2005 1
000080:  34 3A 35 30 3A 32 39 20 : 2B 30 31 30 30            4:50:29 +0100...
[2005-08-08 14:50:29] TCP WRITE [80] -> 127.0.0.1:6588 [23 bytes]
000000:  57 65 20 61 72 65 20 62 : 65 69 6E 67 20 64 65 73   We are being des
000010:  74 72 6F 79 65 64 21    :                           troyed!.........
[2005-08-08 14:50:29] CLOSE [80] -> 127.0.0.1:6588


Actual result:
--------------
(Via a ViewSource)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

(Invalid trace log from Sambar Server)
[2005-08-08 14:48:57] TCP ACCEPT [80] -> 127.0.0.1:6555
[2005-08-08 14:48:57] TCP READWAIT [80] -> 127.0.0.1:6555
[2005-08-08 14:48:57] TCP READ [80] -> 127.0.0.1:6555 [330 bytes]
000000:  47 45 54 20 2F 54 65 73 : 74 25 32 30 7A 6C 69 62   GET /Test%20zlib
000010:  25 32 30 64 65 73 74 72 : 6F 79 2E 70 68 70 20 48   %20destroy.php H
000020:  54 54 50 2F 31 2E 31 0D : 0A 41 63 63 65 70 74 3A   TTP/1.1..Accept:
000030:  20 2A 2F 2A 0D 0A 52 65 : 66 65 72 65 72 3A 20 68    */*..Referer: h
000040:  74 74 70 3A 2F 2F 6C 6F : 63 61 6C 2E 71 75 69 63   ttp://local.quic
000050:  6B 73 63 72 69 70 74 73 : 2F 0D 0A 41 63 63 65 70   kscripts/..Accep
000060:  74 2D 4C 61 6E 67 75 61 : 67 65 3A 20 65 6E 2D 67   t-Language: en-g
000070:  62 0D 0A 41 63 63 65 70 : 74 2D 45 6E 63 6F 64 69   b..Accept-Encodi
000080:  6E 67 3A 20 67 7A 69 70 : 2C 20 64 65 66 6C 61 74   ng: gzip, deflat
000090:  65 0D 0A 55 73 65 72 2D : 41 67 65 6E 74 3A 20 4D   e..User-Agent: M
0000A0:  6F 7A 69 6C 6C 61 2F 34 : 2E 30 20 28 63 6F 6D 70   ozilla/4.0 (comp
0000B0:  61 74 69 62 6C 65 3B 20 : 4D 53 49 45 20 36 2E 30   atible; MSIE 6.0
0000C0:  3B 20 57 69 6E 64 6F 77 : 73 20 4E 54 20 35 2E 31   ; Windows NT 5.1
0000D0:  3B 20 53 56 31 3B 20 2E : 4E 45 54 20 43 4C 52 20   ; SV1; .NET CLR 
0000E0:  31 2E 31 2E 34 33 32 32 : 29 0D 0A 48 6F 73 74 3A   1.1.4322)..Host:
0000F0:  20 6C 6F 63 61 6C 2E 71 : 75 69 63 6B 73 63 72 69    local.quickscri
000100:  70 74 73 0D 0A 43 6F 6E : 6E 65 63 74 69 6F 6E 3A   pts..Connection:
000110:  20 4B 65 65 70 2D 41 6C : 69 76 65 0D 0A 43 61 63    Keep-Alive..Cac
000120:  68 65 2D 43 6F 6E 74 72 : 6F 6C 3A 20 6E 6F 2D 63   he-Control: no-c
000130:  61 63 68 65 0D 0A 43 6F : 6F 6B 69 65 3A 20 52 43   ache..Cookie: RC
000140:  73 6C 62 3D 31 39 0D 0A : 0D 0A                     slb=19..........
[2005-08-08 14:48:57] TCP WRITE [80] -> 127.0.0.1:6555 [169 bytes]
000000:  48 54 54 50 2F 31 2E 31 : 20 32 30 30 20 4F 4B 0D   HTTP/1.1 200 OK.
000010:  0A 44 61 74 65 3A 20 4D : 6F 6E 2C 20 30 38 20 41   .Date: Mon, 08 A
000020:  75 67 20 32 30 30 35 20 : 31 33 3A 34 38 3A 35 37   ug 2005 13:48:57
000030:  20 47 4D 54 0D 0A 53 65 : 72 76 65 72 3A 20 53 41    GMT..Server: SA
000040:  4D 42 41 52 0D 0A 43 6F : 6E 74 65 6E 74 2D 74 79   MBAR..Content-ty
000050:  70 65 3A 20 74 65 78 74 : 2F 68 74 6D 6C 0D 0A 58   pe: text/html..X
000060:  2D 50 6F 77 65 72 65 64 : 2D 42 79 3A 20 50 48 50   -Powered-By: PHP
000070:  2F 35 2E 30 2E 34 0D 0A : 43 6F 6E 74 65 6E 74 2D   /5.0.4..Content-
000080:  45 6E 63 6F 64 69 6E 67 : 3A 20 67 7A 69 70 0D 0A   Encoding: gzip..
000090:  56 61 72 79 3A 20 41 63 : 63 65 70 74 2D 45 6E 63   Vary: Accept-Enc
0000A0:  6F 64 69 6E 67 0D 0A 0D : 0A                        oding...........
[2005-08-08 14:48:57] TCP WRITE [80] -> 127.0.0.1:6555 [155 bytes]
000000:  1F 8B 08 00 00 00 00 00 : 00 03 1C 8C 3D 0F 82 30   .?.........?=.?0
000010:  14 45 77 7E C5 1D DC 34 : F1 61 20 12 04 13 3F 56   .Ew~?.?4?a ...?V
000020:  74 70 70 2E F5 05 AA D2 : 47 DA A2 31 C6 FF 2E BA   tpp.?.??Gڢ1??.?
000030:  DE 73 CE 3D D6 57 D6 01 : DA B1 0A 7C 81 F2 28 7A   ?s?=?W?.ڱ.|.?(z
000040:  C7 6B 7D 57 DE A3 52 37 : DE 49 D7 B1 0D E7 96 ED   ?k}WޣR7?Iױ.???
000050:  96 8D 6D F6 EC 83 93 D7 : E8 BE 23 A0 77 E6 31 86   ?.m?샓???# w?1?
000060:  98 D4 A7 56 9E 7F 36 E8 : 60 C4 1E 24 18 CD 28 31   .ԧV?.6?`?.$.?(1
000070:  0E BC 8A 3E C5 FC 77 5B : 89 9D 81 32 6C 86 06 0B   .??>??w[?..2l?..
000080:  A2 14 71 92 27 59 9E 2E : 31 A5 98 E8 0B 00 00 FF   ?.q?'Y?.1?.?...?
000090:  FF 03 00 42 F5 1E 08 8D : 00 00 00                  ?..B?...........
[2005-08-08 14:48:57] TCP WRITE [80] -> 127.0.0.1:6555 [23 bytes]
000000:  57 65 20 61 72 65 20 62 : 65 69 6E 67 20 64 65 73   We are being des
000010:  74 72 6F 79 65 64 21    :                           troyed!.........
[2005-08-08 14:48:57] CLOSE [80] -> 127.0.0.1:6555


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-08 16:52 UTC] tony2001@php.net
Please try using this CVS snapshot:

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


 [2005-08-09 15:43 UTC] richard dot quadling at bandvulc dot co dot uk
Yep. snapshot for Aug 9 2005 00:33:52 has this fixed.

Thank you, you clever people!

Richard.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC