Issue Details (XML | Word | Printable)

Key: MODPYTHON-182
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jim Gallacher
Reporter: Jim Gallacher
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

Memory leak in request readline()

Created: 11/Aug/06 08:49 PM   Updated: 01/May/07 10:39 AM
Return to search
Component/s: core
Affects Version/s: 3.2.x, 3.3.x, 3.2.10
Fix Version/s: 3.3.1

Time Tracking:
Not Specified

Environment: Apache 2.0.55 mpm-worker

Resolution Date: 17/Sep/06 12:33 PM


 Description  « Hide
There is at least one memory leak request.readline(). I'm currently auditing the code so there may well be others.

I think the leak will only occur when the request body is incompletely read with readline, which is likely an unusual corner case. The following demostrates the leak:

Consider a request body consisting of:

'\n'.join([ 'a'*100 for i in xrange(0, 100) ])

and using this handler:


def handler(req):
    # Handler reads 20 lines but request contains 100 lines.
    # Since the body is not completely read, the buffer allocated
    # in requestobject.c req_readline is never freed.
    req.content_type = 'text/plain'
    count = 0
    for i in range(0, 20):
        line = req.readline()
        count += 1

    req.write('ok readline_partial: %d lines read' % count)
    return apache.OK

With this test setup I'm seeing a leak of approx 10k bytes per request.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Graham Dumpleton made changes - 13/Aug/06 11:14 AM
Field Original Value New Value
Fix Version/s 3.3 [ 12310101 ]
Jim Gallacher made changes - 17/Sep/06 12:33 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Graham Dumpleton made changes - 01/May/07 10:39 AM
Status Resolved [ 5 ] Closed [ 6 ]