From:             wharmby at uk dot ibm dot com
Operating system: Windows XP
PHP version:      5CVS-2006-11-17 (snap)
PHP Bug Type:     Scripting Engine problem
Bug description:  ZMSG_LOG_SCRIPT_NAME not routed to OutputDebugString() on 
Windows

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 bug report at http://bugs.php.net/?id=39548&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39548&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39548&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39548&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39548&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39548&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39548&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39548&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39548&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39548&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39548&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39548&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39548&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39548&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39548&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39548&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39548&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39548&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39548&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39548&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39548&r=mysqlcfg

Reply via email to