Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result - Mailing list pgsql-patches

From Alvaro Herrera
Subject Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result
Date
Msg-id 20080110211640.GU6465@alvh.no-ip.org
Whole thread Raw
Responses Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
Tom Lane escribió:
> Alvaro Herrera <alvherre@commandprompt.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

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Revised patch for fixing archiver shutdown behavior
Next
From: Tom Lane
Date:
Subject: Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result