[mod_python] inspect.getmembers(req) segfaults

Jim Gallacher jpg at jgassociates.ca
Fri Dec 9 12:10:33 EST 2005


Martin Devera wrote:
>>> code:
>>> from mod_python import apache
>>> import os
>>> import inspect
>>>
>>> def handler(req):
>>>          req.content_type = "text/plain"
>>>          m = inspect.getmembers(req);
>>>          req.write("PID "+str(os.getpid())+" "+str(1))
>>>
>>>          return apache.OK
>>>
>>> getmembers line coredumps apache child.
>>
>>
>> Is even easier than that. Simply access 'req.boundary' and it crashes.
>>
>> The code contains:
>>
>>     {"boundary",     (getter)getreq_recmbr, NULL, 
>> "Multipart/byteranges boundary", "boundary"},
>>
>> in the request_getsets[] array, but there is no definition of 
>> 'boundary' in
>> the request_rec_mbrs[] array. As a consequence, when you access it, it
>> will crash.
>>
>> The 'boundary' line therefore needs to be deleted from the source as it
>> appears to serve no purpose.
>>
>> I'll log a bug report.
> 
> 
> Hello Graham,
> 
> I fixed the boundary problem temporarily and found another. And it
> seems to be harder (I'm looking at it in GDB for 3 hours now):
> 
> def handler(req):
>         req.content_type = "text/plain"
>         req.write("EE\n")
>         a = getattr(req,"allowed_methods");
>     return apache.OK
> 
> Coredumps in getreq_rec_ml...

I stuffed some ap_log_rerror statements into getreq_rec_ml and every 
thing is fine up to  "return tuple_from_method_list(ml);".

tuple_from_method_list is defined in src/util.c. I'm out of time right 
now but I'll poke at it later and see what I can learn.

Jim




More information about the Mod_python mailing list