quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Gallacher <...@jgassociates.ca>
Subject Re: [jira] Commented: (MODPYTHON-172) Memory leak with util.fieldstorage using mod_python 3.2.8 on apache 2.0.55
Date Sat, 08 Jul 2006 01:26:01 GMT
Graham Dumpleton wrote:
> On first look I would agree there is possibly a problem. There also
> would appear to be
> similar issues in other parts of mod_python. For example in
> cfgtree_walk() of util.c it has:
> 
>         PyObject *t = Py_BuildValue("(s, s)", dir->directive, dir->args);
>         if (!t)
>             return PyErr_NoMemory();
> 
>         PyList_Append(list, t);
> 
> with "t" not being DECREF'd either.
> 
> Also, in req_readlines() of requestobject.c, we have:
> 
>     line = req_readline(self, rlargs);
>     while (line && (PyString_Size(line)>0)) {
>         PyList_Append(result, line);
>         size += PyString_Size(line);
>         if ((sizehint != -1) && (size >= size))
>             break;
>         line = req_readline(self, args);
>     }
> 
> No DECREF for item added to list.
> 
> I can't see any others in relation to dictionaries yet, but we probably
> need to do a good
> audit of all the code for such things as I have only check
> PyList_Append() and
> PyDict_SetItem() and not the other ways stuff can be added to such data
> structures.
> 
> Anyway, still need to run some tests yet to confirm memory leak. :-)

I've been working through the PyList_Append instances and noticed the
cfgtree_walk and req_readlines issues as well. I've confirmed that
cfgtree_walk does indeed leak. I haven't tested req_readlines but I
can't see why it wouldn't leak.

Can you spot the other bug in req_readlines? Hint: (size >= size) will
always be true. ;) Once that is fixed I think we need to alter the docs
for req.readlines() as I'm not sure the description for sizehint
accurately reflects the way it works.

Jim

> Graham
> 
> On 08/07/2006, at 1:05 AM, Harold Ship (JIRA) wrote:
> 
>>     [
>> http://issues.apache.org/jira/browse/MODPYTHON-172?page=comments#action_12419728
>> ]
>>
>> Harold Ship commented on MODPYTHON-172:
>> ---------------------------------------
>>
>> Please look at lines 202-205 of the same file, in parse_qs() :
>>
>>                     PyObject *list;
>>                     list = Py_BuildValue("[O]", val);
>>                     PyDict_SetItem(dict, key, list);
>>                     Py_DECREF(list);
>>
>>
>>
>>> Memory leak with util.fieldstorage using mod_python 3.2.8 on apache
>>> 2.0.55
>>> --------------------------------------------------------------------------
>>>
>>>
>>>          Key: MODPYTHON-172
>>>          URL: http://issues.apache.org/jira/browse/MODPYTHON-172
>>>      Project: mod_python
>>>         Type: Bug
>>
>>>   Components: core
>>>     Versions: 3.2.8
>>>  Environment: Win32 XP  SP1 / SP2
>>> Apache 2.0.55  installed from binary (.MSI)
>>> Python 2.4.2  or  2.4.3    installed from binary from www.python.org
>>>     Reporter: Laurent Blanquet
>>
>>>
>>> I encounter memory leaks [~ 16 K per request) using the configuration
>>> described below.
>>> =============================
>>> Python configuration from Httpd.conf:
>>> =============================
>>> Alias /python/ "d:/python24/B2B/"
>>> <Directory "d:/python24/B2B">
>>>         AddHandler mod_python .py
>>>         PythonHandler pyHandlerHTTP
>>>         PythonDebug On
>>> </Directory>
>>> =============================
>>> Test handler -  pyHandlerHTTP.py :
>>> =============================
>>> import mod_python
>>> from mod_python import util
>>> def handler(req):
>>>       #Removing this line solves the problem.
>>>       F=util.FieldStorage( req )
>>>       return mod_python.apache.OK
>>> =============================
>>> HTTP Request (dump using TCPWATCH):
>>> =============================
>>> POST http://localhost:80/python/Alertes.py HTTP/1.0
>>> Content-Type: multipart/form-data; boundary=--------061006144341906
>>> Content-Length: 209
>>> Proxy-Connection: keep-alive
>>> Host: www.tx2-localhost
>>> Accept: text/html, */*
>>> User-Agent: Mozilla/3.0 (compatible; Indy Library)
>>> Proxy-Authorization: Basic Og==
>>>
>>> ----------061006144341906
>>> Content-Disposition: form-data; name="TYPE"
>>>
>>> LAST_ALERTS
>>> ----------061006144341906
>>> Content-Disposition: form-data; name="FILEAGE"
>>>
>>> 180
>>>
>>> ----------061006144341906
>>
>> --This message is automatically generated by JIRA.
>> -
>> If you think it was sent incorrectly contact one of the administrators:
>>    http://issues.apache.org/jira/secure/Administrators.jspa
>> -
>> For more information on JIRA, see:
>>    http://www.atlassian.com/software/jira
> 
> 


Mime
View raw message