[mod_python] invalid pointer, child process dies, broken connections

Richard Lewis richardlewis at fastmail.co.uk
Fri Nov 24 08:42:53 EST 2006


Thanks for these pointers:

On Thursday 23 November 2006 21:08, Graham Dumpleton wrote:
> Only suggestions at this point are:
>
> 1. Use:
>
>   PythonInterpreter main_interpreter
>
Didn't seem to make any difference.

>
> Note that this only applies for mod_python 3.2.10 and later.
>
> 2. Read through:
>
>   http://www.dscpl.com.au/wiki/ModPython/Articles/ExpatCausingApacheCrash
>
I tried this and the expat test worked fine. I'm pretty sure lxml doesn't use 
expat (because it uses libxml instead).

>
> 3. Run Apache in single process mode and attach a debugger process
> ...
> Type 'cont' command to gdb and then start sending requests until it
> crashes. Then use 'where' to get a stack trace.
>
OK. I've just tried this. I'm not all that familiar with gdb (I'm not a C 
programmer) but I managed to get it to work, though my session was a bit 
different to yours.

I think it may have highlighted the source of the problem. I don't know 
whether you know, but one of the reasons why the lxml module was created was 
because of memory management problems with the standard Python bindings to 
libxml. It seems that the stack trace I've got is showing exactly these 
problems:

#4  0xb7bd0811 in raise () from /lib/tls/i686/cmov/libc.so.6
#5  0xb7bd1fb9 in abort () from /lib/tls/i686/cmov/libc.so.6
#6  0xb7c05c8a in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
#7  0xb7c0d51f in mallopt () from /lib/tls/i686/cmov/libc.so.6
#8  0xb7c0d5c2 in free () from /lib/tls/i686/cmov/libc.so.6
#9  0xb727155d in xmlFreeNodeList () from /usr/lib/libxml2.so.2
#10 0xb72716a2 in xmlFreeProp () from /usr/lib/libxml2.so.2
#11 0xb727191b in xmlFreePropList () from /usr/lib/libxml2.so.2
#12 0xb72714fa in xmlFreeNodeList () from /usr/lib/libxml2.so.2
#13 0xb72714d6 in xmlFreeNodeList () from /usr/lib/libxml2.so.2
#14 0xb72714d6 in xmlFreeNodeList () from /usr/lib/libxml2.so.2
#15 0xb72712fe in xmlFreeDoc () from /usr/lib/libxml2.so.2
#16 0xb73edcc6 in initTagMatch () 
from /usr/lib/python2.4/site-packages/lxml/etree.so
#17 0xb73edaec in initTagMatch () 
from /usr/lib/python2.4/site-packages/lxml/etree.so
#18 0xb73b3826 in iteratorStoreNext () 
from /usr/lib/python2.4/site-packages/lxml/etree.so
#19 0xb73b368c in iteratorStoreNext () 
from /usr/lib/python2.4/site-packages/lxml/etree.so
#20 0xb73b8b06 in iteratorStoreNext () 
from /usr/lib/python2.4/site-packages/lxml/etree.so
#21 0xb775b255 in PyTuple_Size () from /usr/lib/libpython2.4.so.1.0
#22 0xb7786fe3 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
#23 0xb77878a5 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
#24 0xb77878a5 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
#25 0xb778878a in PyEval_EvalCodeEx () from /usr/lib/libpython2.4.so.1.0
#26 0xb77381c0 in PyClassMethod_New () from /usr/lib/libpython2.4.so.1.0
#27 0xb771d237 in PyObject_Call () from /usr/lib/libpython2.4.so.1.0
#28 0xb7724a72 in PyClass_IsSubclass () from /usr/lib/libpython2.4.so.1.0
#29 0xb771d237 in PyObject_Call () from /usr/lib/libpython2.4.so.1.0
#30 0xb771f67e in PyObject_CallMethod () from /usr/lib/libpython2.4.so.1.0
#31 0xb7836455 in python_cleanup () 
from /usr/lib/apache2/modules/mod_python.so
#32 0xb7837e1a in python_cleanup () 
from /usr/lib/apache2/modules/mod_python.so
#33 0x08074587 in ap_run_handler ()
#34 0x08077731 in ap_invoke_handler ()
#35 0x08084728 in ap_process_request ()
#36 0x080819ce in ap_register_input_filter ()
#37 0x0807b3c7 in ap_run_process_connection ()
#38 0x08088704 in ap_graceful_stop_signalled ()
#39 0x08088964 in ap_graceful_stop_signalled ()
#40 0x0808972a in ap_mpm_run ()
#41 0x080621ef in main ()

I don't know what the answer is, though?

The strange thing is that I've used lxml with mod_python before (in my Pycoon 
project) and I've never had this problem - I hope I'm not about to run into 
it in the near future!

> 4. It would also be a good idea to simply start paring back the code of
> your application bit by bit

Yes, this is a good idea, but very unappealing ;-)

>
> 5. Try the dev snapshot of mod_python 3.3.

OK, I may try this later on, the only thing is that I'm a Debian user and so 
am quite averse to manual compilation/installation ;-)

>
> 6. Post just the part of your Apache configuration which relates to how you
> trigger mod_python and in what context. From that I might see if you are
> managing to hit any of the issues referred to in 5.
>
This is my whole config:

NameVirtualHost *

<VirtualHost *>
    ServerName localhost
    DocumentRoot /home/richard/Documents/sara/python

    SetHandler mod_python
    #PythonInterpreter main_interpreter
    PythonPath 'sys.path+["/home/richard/Documents/sara/python"]'
    #PythonDebug on

    PythonHandler sara.web
</VirtualHost>

Thanks for your help!

Cheers,
Richard

>
> Richard Lewis wrote ..
>
> > Hi there,
> >
> > Debian unstable; apache: 2.2.3; modpython: 3.2.10; python: 2.4.4; lxml
> > 1.1.1:
> > libxml: 2.6.16; libxslt: 1.1.8.
> >
> > I posted on 2nd Nov about some invalid pointer errors in my Apache error
> > log.
> > At the time I thought they were coming from MySQL and received some
> > interesting replies regarding the incompatibility of the mysql client
> > libraries compiled into various apache modules.
> >
> > However, since then I've decided to cut MySQL out of my web application
> > and,
> > instead of dynamically converting database records into XML, use
> > filesystem-cached XML files which are generated periodically from the
> > database by a separate process.
> >
> > While there are a couple of other advantages to this approach, it hasn't
> > solved my initial problem! I still have numerous errors like this in my
> > Apache error log:
> >
> > [Mon Nov 20 10:51:58 2006] [notice] child pid 7087 exit signal Aborted
> > (6)
> > *** glibc detected *** free(): invalid pointer: 0x0835ab26 ***
> > *** glibc detected *** free(): invalid pointer: 0x0835ab26 ***
> > *** glibc detected *** free(): invalid pointer: 0x0835ab26 ***
> > *** glibc detected *** free(): invalid pointer: 0x0835ab26 ***
> > [Mon Nov 20 10:54:28 2006] [notice] child pid 7088 exit signal Aborted
> > (6)
> > [Mon Nov 20 10:54:28 2006] [notice] child pid 7089 exit signal Aborted
> > (6)
> > [Mon Nov 20 10:54:28 2006] [notice] child pid 7098 exit signal Aborted
> > (6)
> >
> > It seems to handle several requests and then you get an error message
> > from the
> > client (browser) saying that "the connection is broken". You can then
> > retry the request and it works after one or two attempts.
> >
> > I /think/ there is no direct correlation between the invalid pointer
> > errors messages and the dropped connections; the times of the messages
> > seem to be
> > pretty evenly distributed and don't all result in a broken connection.
> >
> > Also, the memory addresses of the invalid pointers are often (but not
> > always) the same. While the child process ids are always different. What
> > is the child
> > process? Is it python?
> >
> > I've checked to make sure that I'm always returning the content length
> > and
> > Apache status code; I'm pretty sure I am! My application is using a
> > frameset where the frame document and its four frames are all generated
> > using mod_python. Is there anything special I should do to help
> > mod_python with this? (Like returning special Apache status codes?)
> >
> > Apart from getting these errors, my code is pretty much ready to go live.
> > So
> > it would be really great if anyone could help me sort out this problem!
> >
> > Cheers,
> > Richard
> > --
> > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> > Richard Lewis
> > Sonic Arts Research Archive
> > http://www.sara.uea.ac.uk/
> > JID: ironchicken at jabber.earth.li
> > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_python
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Richard Lewis
Sonic Arts Research Archive
http://www.sara.uea.ac.uk/
JID: ironchicken at jabber.earth.li
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


More information about the Mod_python mailing list