Skip site navigation (1) Skip section navigation (2)

Re: BUG #3860: xpath crashes backend when is queryingxmlagg result

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Sokolov Yura <funny(dot)falcon(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org, Peter Eisentraut <peter_e(at)gmx(dot)net>, Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: BUG #3860: xpath crashes backend when is queryingxmlagg result
Date: 2008-01-10 21:16:40
Message-ID: 20080110211640.GU6465@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-patches
Tom Lane escribió:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:

> > Perhaps a better idea is to create a separate LibxmlContext memcxt,
> > child of QueryContext, and have xml_palloc etc always use that.  That
> > way it won't be reset between calls.  It probably also means we could
> > wire xml reset to transaction abort, making it a bit simpler.
> 
> Might as well go back to letting it use malloc :-(.
> 
> I actually don't see a problem with letting it use malloc for stuff that
> it is going to manage for itself.  I guess the problem comes with
> transient return values of libxml functions; we'd want to explicitly
> move those into palloc-based storage and then free() them.
> 
> This looks like a rather large rewrite though.  Peter, have you any
> better ideas?

OK, after a lot of research I think the best way to deal with this is
what I suggest above.  With the attached patch, I cannot cause the
system to crash with any of the given examples.

Furthermore this may help clean up the PG_TRY blocks that are currently
sprinkled through the xml.c code.

Handling of subtransactions is no good at this point, but I think that
could easily be improved.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment: xml-2.patch
Description: text/x-diff (5.9 KB)

In response to

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2008-01-10 22:00:02
Subject: Re: BUG #3865: ERROR: failed to build any 8-way joins
Previous:From: Alvaro HerreraDate: 2008-01-10 20:19:41
Subject: Re: BUG #3860: xpath crashes backend when is queryingxmlagg result

pgsql-patches by date

Next:From: Tom LaneDate: 2008-01-11 00:23:06
Subject: Re: BUG #3860: xpath crashes backend when is querying xmlagg result
Previous:From: Alvaro HerreraDate: 2008-01-10 20:19:41
Subject: Re: BUG #3860: xpath crashes backend when is queryingxmlagg result

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group