php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39548 ZMSG_LOG_SCRIPT_NAME not routed to OutputDebugString() on Windows
Submitted: 2006-11-17 16:00 UTC Modified: 2006-11-23 08:38 UTC
From: wharmby at uk dot ibm dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2006-11-17 (snap) OS: Windows XP
Private report: No CVE-ID: None
 [2006-11-17 16:00 UTC] 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 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-23 08:38 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_2.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC