Uploaded image for project: 'mod_python'
  1. mod_python
  2. MODPYTHON-182

Memory leak in request readline()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.x, 3.3.x, 3.2.10
    • 3.3.1
    • core
    • None
    • Apache 2.0.55 mpm-worker

    Description

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

      1. Handler reads 20 lines but request contains 100 lines.
      2. Since the body is not completely read, the buffer allocated
      3. 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.

      Attachments

        Activity

          People

            jgallacher James Paul Gallacher
            jgallacher James Paul Gallacher
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: