Re: BUG #3860: xpath crashes backend when is querying xmlagg 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 querying xmlagg result
Date: 2008-01-10 21:16:40
Message-ID: 20080110211640.GU6465@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-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 Content-Type Size
xml-2.patch text/x-diff 5.9 KB

In response to

Responses

Browse pgsql-bugs by date

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

Browse pgsql-patches by date

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