mod_python
  1. mod_python
  2. MODPYTHON-234

SystemError: bad argument to internal function

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.2.10, 3.3.1
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None

      Description

      As raised in thread:

      http://www.modpython.org/pipermail/mod_python/2007-June/023795.html

      when req.read() is called, on rare occasions it can generate the error:

      05 18:33:49 2007] [error] [client 200.155.85.225] SystemError: Objects/stringobject.c:3515: bad argument to internal function,

      It is speculated that this is caused by an invalid value being supplied to _PyString_Resize() with code associated with req.read(). In particular, most likely being supplied a negative value for size.

      This issues possibly relates to problems with how mod_python makes use of content length and what request_rec says in respect of remaining amount of data as described in MODPYTHON-212.

      Further highlights how the code for req.read(), req.readline() and req.readlines() has to be completely revised and overhauled to simply read whatever is available rather than trusting content length.

        Activity

        Hide
        Alex Cichowski added a comment -

        If Matthew Woodcraft's analysis is correct, the patch attached to MODPYTHON-222 should fix this.

        Show
        Alex Cichowski added a comment - If Matthew Woodcraft's analysis is correct, the patch attached to MODPYTHON-222 should fix this.
        Hide
        Matthew Woodcraft added a comment -

        In req_read() (as of 3.3.1), the return value of the first call to ap_get_client_block() isn't checked for errors.

        If this call returns -1 and the following call to ap_get_client_block() returns
        0, it seems to me that the result would be a call to _PyString_Resize with size -1, which matches the SystemError above.

        Show
        Matthew Woodcraft added a comment - In req_read() (as of 3.3.1), the return value of the first call to ap_get_client_block() isn't checked for errors. If this call returns -1 and the following call to ap_get_client_block() returns 0, it seems to me that the result would be a call to _PyString_Resize with size -1, which matches the SystemError above.
        Hide
        Graham Dumpleton added a comment -

        This error also seen by someone using Django and LimitRequestBody directive.

        http://groups.google.com/group/django-users/browse_frm/thread/fb72bd122ae283ad/fa18c0f8a294f5d1#fa18c0f8a294f5d1

        This directive may perhaps be a way of reproducing the problem allowing it to be tracked down.

        Do note though that as a separate issue, mod_python doesn't work properly with LimitRequestBody. This is described in that discussion but I haven't logged it as a separate issue yet.

        Show
        Graham Dumpleton added a comment - This error also seen by someone using Django and LimitRequestBody directive. http://groups.google.com/group/django-users/browse_frm/thread/fb72bd122ae283ad/fa18c0f8a294f5d1#fa18c0f8a294f5d1 This directive may perhaps be a way of reproducing the problem allowing it to be tracked down. Do note though that as a separate issue, mod_python doesn't work properly with LimitRequestBody. This is described in that discussion but I haven't logged it as a separate issue yet.

          People

          • Assignee:
            Unassigned
            Reporter:
            Graham Dumpleton
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development