php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25844 General memory leak
Submitted: 2003-10-12 06:53 UTC Modified: 2003-10-12 20:00 UTC
From: jakub at icewarp dot com Assigned:
Status: Not a bug Package: IIS related
PHP Version: 4.3.4RC1 OS: Windows (Any)
Private report: No CVE-ID: None
 [2003-10-12 06:53 UTC] jakub at icewarp dot com
Description:
------------
This problem is hardly to be reproduced in CGI because the module is always released after finish. So the only way to reproduce it for me is the ISAPI module. You can use some web traffic tool and simulate a 1000 web accesses to any PHP script and see the memory of the ISAPI handler leaks. 

I'm using my own web server engine so I found out that 1000 hits to a simple <? phpinfo(); ?> page leaks about 700kb.

I started debugging and compiling my own PHP core and found out this:

Having the body of the funtion like this:
DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)
{ return 0; }

leaks no memory. So we proved it's not the web server engine that leaks (other ISAPI modules do not leak anyway).

Using the most simple body like this:

2. 1. HttpExtensionProc like this does leak.
DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)
{
	TSRMLS_FETCH();
	ts_free_thread();
        return 0;
}

Leaks the memory as discussed above. So I kept digging more.


Then I found the call that actually leaks the memory is:

	TSRM_SAFE_RETURN_RSRC(thread_resources->storage, id,
thread_resources->count);

In the function:
TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)

The problem is with the 
return &array;
Call which leaks the memory. If I remove it it does not leak. If I remove the pointer character it does not leak.

So the question is why does the return call leak when passing back the pointer? I'm not a C++ guru so I can't make this out. 

I had to post it here because when I posted the problem to ISAPI section nobody cared. This problem has been there for the last 2 years for sure. The leak is 100% reproducable and the question is why wouldn't it leak on Linux....

Please help us here? Thank you
Jakub


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-12 20:00 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.

Thank you for your interest in PHP.

See bug #23331

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 20:01:35 2024 UTC