Apache Mod-Python - Re: Commented: (MODPYTHON-172) Memory leak with util.fieldstorage

This is Interesting: Free IT Magazines  
Home > Archive > Apache Mod-Python > July 2006 > Re: Commented: (MODPYTHON-172) Memory leak with util.fieldstorage





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Commented: (MODPYTHON-172) Memory leak with util.fieldstorage
Jim Gallacher

2006-07-08, 1:12 am

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:
>
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com