[Fwd: Re: [mod_python] psp.PSP(req, string='hello world') causessegfault]

Graham Dumpleton grahamd at dscpl.com.au
Tue Apr 26 20:46:25 EDT 2005


Following code in _psp_module_parsestring() looks suspect to me:

    yy_delete_buffer(bs, scanner);
    yylex_destroy(scanner);

There are already calls to yy_delete_buffer() in yylex_destroy(). If I
comment out the call to yy_delete_buffer() I no longer get the
double delete warning. I still get the Python error below though,
so that is the next thing to solve.

Graham

Graham Dumpleton wrote ..
> It may not be your platform, but a problem in the C code part of PSP
> modules after all. On Mac OSX, after making the Python changes you
> give, it doesn't crash, but do get this warning in the logs.
> 
> [Wed Apr 27 10:21:14 2005] [notice] Apache/2.0.51 (Unix) mod_python/3.1.3
> Python/2.3 configured -- resuming normal operations
> *** malloc[595]: Deallocation of a pointer not malloced: 0x528050; This
> could be a double free(), or free() called with the middle of an allocated
> block; Try setting environment variable MallocHelp to see tools to help
> debug
> *** malloc[595]: error for object 0x5102c0: Double free
> [Wed Apr 27 10:21:16 2005] [error] [client 127.0.0.1] PythonHandler _handler:
> Traceback (most recent call last):
> [Wed Apr 27 10:21:16 2005] [error] [client 127.0.0.1] PythonHandler _handler:
> File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/mod_python/apache.py",
> line 308, in HandlerDispatch\n    result = object(req)
> [Wed Apr 27 10:21:16 2005] [error] [client 127.0.0.1] PythonHandler _handler:
> File "/Users/grahamd/Sites/psp_crash/_handler.py", line 6, in handler\n
> content_file.run()
> [Wed Apr 27 10:21:16 2005] [error] [client 127.0.0.1] PythonHandler _handler:
> File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/mod_python/psp.py",
> line 190, in run\n    if "session" in code.co_names:
> [Wed Apr 27 10:21:16 2005] [error] [client 127.0.0.1] PythonHandler _handler:
> AttributeError: 'str' object has no attribute 'co_names' 
> 
> I haven't looked at the Python traceback bit yet, but the fact that malloc
> is complaining suggests that some sort of memory manipulation is
> wrong.
> 
> Graham
> 
> 
> dharana wrote ..
> > There where more typos. I think I've fixed them. I am now trying to 
> > reproduce it in another machine. I'm starting to believe it must a 
> > problem with my server setup what is causing the segfaults.
> > 
> > -------- Original Message --------
> > Subject: Re: [mod_python] psp.PSP(req, string='hello world') causes segfault
> > Date: Wed, 27 Apr 2005 00:49:08 +0200
> > From: dharana <dharana at dharana.net>
> > To: dharana <dharana at dharana.net>
> > CC: Graham Dumpleton <grahamd at dscpl.com.au>,  mod_python list 
> > <mod_python at modpython.org>,  python-dev at httpd.apache.org
> > References: <426EB09B.60804 at dharana.net> 
> > <cd668e4f1acb033939973727c751beb6 at dscpl.com.au> 
> > <426EB7C7.4030307 at dharana.net> 
> > <9f4387af79e092bc1b49d90c29633edc at dscpl.com.au> 
> > <426EC2D1.7080401 at dharana.net>
> > 
> > There where 3 typos in psp.py. I could only fix them by temporarily
> > commenting out the _psp.parsestring call. I leave to you the C side :)
> > 
> > I've included the patch file with the typos fixed. Hope it helps. I'm
> > also forwarding to python-dev because I believe I've crossed the line
> again.
> > 
> > -----------------------------------------------------------------------
> > --- /usr/src/mod_python-3.1.4/lib/python/mod_python/psp.py      Sat Jan
> > 29 22:25:29 2005
> > +++ /usr/local/hosting/lib/python2.4/site-packages/mod_python/psp.py
> > Wed Apr 27 00:43:06 2005
> > @@ -111,12 +111,12 @@
> >               self.load_from_file()
> >           else:
> > 
> > -            cached = strcache.get(string)
> > +            cached = mem_scache.get(string)
> >               if cached:
> >                   self.code = cached
> >               else:
> >                   self.code = _psp.parsestring(string)
> > -                strcache.store(string)
> > +                mem_scache.store(string, self.code)
> > 
> >       def cache_get(self, filename, mtime):
> > 
> > @@ -358,8 +358,8 @@
> > 
> >       def get(self, key):
> >           if self.cache.has_key(key):
> > -            hist, val = self.cache[key]
> > -            self.cache[key] = (hits+1, code)
> > +            hits, val = self.cache[key]
> > +            self.cache[key] = (hits+1, val)
> >               return val
> >           else:
> >               return None
> > -----------------------------------------------------------------------
> > 
> > -- 
> > dharana
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python


More information about the Mod_python mailing list