Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-15 Thread Sokolov Yura
Tom Lane wrote: "Sokolov Yura" <[EMAIL PROTECTED]> writes: xpath() crashes backend when is querying particular xmlagg results. Please see whether this patch fixes it: http://archives.postgresql.org/pgsql-committers/2008-01/msg00190.php The specific examples you give seem to be fixed,

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-12 Thread Tom Lane
"Sokolov Yura" <[EMAIL PROTECTED]> writes: > xpath() crashes backend when is querying particular xmlagg results. Please see whether this patch fixes it: http://archives.postgresql.org/pgsql-committers/2008-01/msg00190.php The specific examples you give seem to be fixed, but that's not very much

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-10 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Tom Lane escribió: >> One thing I was wondering about earlier today is whether libxml isn't >> expecting NULL-return-on-failure from the malloc-substitute routine. >> If we take control away from it unexpectedly, I wouldn't be a bit >> surprised if its d

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-10 Thread Alvaro Herrera
Tom Lane escribió: > One thing I was wondering about earlier today is whether libxml isn't > expecting NULL-return-on-failure from the malloc-substitute routine. > If we take control away from it unexpectedly, I wouldn't be a bit > surprised if its data structures are left corrupt. This might lea

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-10 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > + void > + AtEOXact_xml(void) > + { > + if (LibxmlContext == NULL) > + return; > + > + MemoryContextDelete(LibxmlContext); > + LibxmlContext = NULL; > + > + xmlCleanupParser(); > + } [ blink... ] Shouldn't that be the othe

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-10 Thread Alvaro Herrera
Tom Lane escribió: > Alvaro Herrera <[EMAIL PROTECTED]> 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 r

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-10 Thread Alvaro Herrera
Alvaro Herrera escribió: > Tom Lane escribió: > > > We might be able to compromise by only resetting the context after > > an error, but this is still only possible if we have a way to make > > libxml let go of *all* pointers to alloc'd objects. I don't understand > > your comment that xmlCleanup

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Alvaro Herrera
Tom Lane escribió: > I wonder whether the real issue here isn't that we have some functions > that invoke libxml without ultimately doing xmlCleanupParser() --- > xml_in being the first obvious candidate. Maybe that is the mechanism > through which libxml ends up with dangling pointers. Hmm. I s

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Tom Lane
I wonder whether the real issue here isn't that we have some functions that invoke libxml without ultimately doing xmlCleanupParser() --- xml_in being the first obvious candidate. Maybe that is the mechanism through which libxml ends up with dangling pointers. regards, tom

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Alvaro Herrera
Tom Lane escribió: > We might be able to compromise by only resetting the context after > an error, but this is still only possible if we have a way to make > libxml let go of *all* pointers to alloc'd objects. I don't understand > your comment that xmlCleanupParser solves it --- we call that alr

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Alvaro Herrera
Alvaro Herrera escribió: > Tom Lane escribió: > > > We might be able to compromise by only resetting the context after > > an error, but this is still only possible if we have a way to make > > libxml let go of *all* pointers to alloc'd objects. I don't understand > > your comment that xmlCleanup

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Alvaro Herrera
Tom Lane escribió: > We might be able to compromise by only resetting the context after > an error, but this is still only possible if we have a way to make > libxml let go of *all* pointers to alloc'd objects. I don't understand > your comment that xmlCleanupParser solves it --- we call that alr

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > What problem you have with it having its own memory context? I don't > think it has any particular disadvantage. I don't object to that per se; I'm just saying it doesn't do much to fix the problem. The difficulty we've got here ultimately comes down

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Alvaro Herrera
Tom Lane escribió: > Alvaro Herrera <[EMAIL PROTECTED]> writes: > > What's happening is that libxml encoding handler table is being > > allocated in an ExprContext which apparently is too short-lived. > > > I'm not seeing very well how to handle this -- one idea would be to > > manually call xmlIn

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > What's happening is that libxml encoding handler table is being > allocated in an ExprContext which apparently is too short-lived. > I'm not seeing very well how to handle this -- one idea would be to > manually call xmlInitCharEncodingHandlers (which i

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Alvaro Herrera
Tom Lane escribió: > Alvaro Herrera <[EMAIL PROTECTED]> writes: > > Hmm, what I'm seeing is that libxml is apparently trying to pfree > > something that it didn't allocate via palloc ... > > Not totally surprising --- when we call xmlMemSetup() we are telling > libxml to start using xml_palloc etc

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Hmm, what I'm seeing is that libxml is apparently trying to pfree > something that it didn't allocate via palloc ... Not totally surprising --- when we call xmlMemSetup() we are telling libxml to start using xml_palloc etc rather than its default of mal

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Alvaro Herrera
Tom Lane escribió: > Alvaro Herrera <[EMAIL PROTECTED]> writes: > > I can reproduce this crash. The backtrace looks like this: Hmm, what I'm seeing is that libxml is apparently trying to pfree something that it didn't allocate via palloc ... -- Alvaro Herrerahtt

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > I can reproduce this crash. The backtrace looks like this: Ah, good. This looks like it matches a previous report, but we didn't have a reproducible test case: http://archives.postgresql.org/pgsql-general/2007-12/msg01086.php

Re: [BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Alvaro Herrera
Sokolov Yura escribió: > bg1.sql--- > -- crashed, when queries xmlelement with containment given by xmlagg > -- and type of aggregated elements is different > select xpath('any_non_empty_expression', xmlelement(name a, xmlagg(el) )) as > el > from ( values > ( xmlelement(

[BUGS] BUG #3860: xpath crashes backend when is querying xmlagg result

2008-01-09 Thread Sokolov Yura
The following bug has been logged online: Bug reference: 3860 Logged by: Sokolov Yura Email address: [EMAIL PROTECTED] PostgreSQL version: 8.3beta4 Operating system: Debian Linux 4.0r2 both 32bit and amd64 Description:xpath crashes backend when is querying xmlagg resu