ID: 39548
Updated by: [EMAIL PROTECTED]
Reported By: wharmby at uk dot ibm dot com
-Status: Assigned
+Status: Closed
Bug Type: Scripting Engine problem
Operating System: Windows XP
PHP Version: 5CVS-2006-11-17 (snap)
Assigned To: dmitry
New Comment:
Fixed in CVS HEAD and PHP_5_2.
Previous Comments:
------------------------------------------------------------------------
[2006-11-17 16:00:58] wharmby at uk dot ibm dot com
Description:
------------
I have been playing around with the Zend Memory Manager leak
detection code and have found that when I cause a memory
leak the messages produced by the leak detection code go to 2 different
destinations:
(1) A single line message detailing the script name which
caused the leak is sent to stderr although the message
itself gives no indication of why its being produced, but
(2) The details of the leak (address, filename, line number etc) go to
OutputDebugString()
I am running DebugView from :
(www.microsoft.com/technet/sysinternals/utilities/debugview.mspx)
to capture the messages and I see messages like:
[Fri Nov 17 15:32:28 2006] Script: 'helloWorld.php'
at stderr but the detail about the leak, e.g
[3096] c:\phpdev\php5.2-200611171130\zend\zend_vm_execute.h(52) :
Freeing 0x01101B68 (0 bytes), script=helloWorld.php
is in my DebugView log.
The stderr message on its own is of very little use unless
it can be paired with the corresponding detail message. As
the 2 messages go to different destinations this has to be
done by comparing time stamps; possible but less than ideal. I can
think of no good reason why the "script name" message is sent to stderr
rather than DebugOutputString() so I
assume this is just an oversight.
Easy to fix my modifying the php_message_handler_for_zend()
code to correctly route the ZMSG_LOG_SCRIPT_NAME message to
OutputDebugString() on Windows.
A patch to implement my suggested fix is here:
http://pastebin.ca/250948
Reproduce code:
---------------
To cause the memory leak in the first place I just hacked the
code in zend_alloc.c method _zend_mm_free_int() such that it returns
immediately without freeing anything. Then running a
simple "HelloWorld" script using CLI produces many leak
messages.
Expected result:
----------------
No messages to stderr and all leak messages in DebugView log
Actual result:
--------------
Majority of output in DebugView log but multiple instances of
just the ZMSG_LOG_SCRIPT_NAME message at stderr, e.g
C:\Eclipse-PHP\workspace\Testcases>php -f helloWorld.php
[Fri Nov 17 15:36:21 2006] Script: 'helloWorld.php'
[Fri Nov 17 15:36:21 2006] Script: 'helloWorld.php'
[Fri Nov 17 15:36:21 2006] Script: 'helloWorld.php'
[Fri Nov 17 15:36:21 2006] Script: 'helloWorld.php'
[Fri Nov 17 15:36:21 2006] Script: 'helloWorld.php'
[Fri Nov 17 15:36:21 2006] Script: 'helloWorld.php'
[Fri Nov 17 15:36:21 2006] Script: 'helloWorld.php'
[Fri Nov 17 15:36:21 2006] Script: 'helloWorld.php'
etc
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39548&edit=1