Re: remove contrib/xml2 - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: remove contrib/xml2
Date
Msg-id 20100218140945.GA6317@alvh.no-ip.org
Whole thread Raw
In response to Re: remove contrib/xml2  (M Z <jm80008@gmail.com>)
Responses Re: remove contrib/xml2
List pgsql-hackers
M Z escribió:
> Hi Alvaro,
> 
> I followed your instruction but put the patch on 8.4.2 as I found it
> crashes. It looks like the server still crash in the same way. Can you and
> anyone give me some ideas how to fix this bug?

See src/backend/utils/adt/xml.c.  Note the comment at the top:

/** Notes on memory management:** Sometimes libxml allocates global structures in the hope that it can reuse* them
lateron.  This makes it impractical to change the xmlMemSetup* functions on-the-fly; that is likely to lead to trying
topfree() chunks* allocated with malloc() or vice versa.  Since libxml might be used by* loadable modules, eg libperl,
ouronly safe choices are to change the* functions at postmaster/backend launch or not at all.  Since we'd rather* not
activatelibxml in sessions that might never use it, the latter choice* is the preferred one.  However, for debugging
purposesit can be awfully* handy to constrain libxml's allocations to be done in a specific palloc* context, where
they'reeasy to track.  Therefore there is code here that* can be enabled in debug builds to redirect libxml's
allocationsinto a* special context LibxmlContext.  It's not recommended to turn this on in* a production build because
ofthe possibility of bad interactions with* external modules.*/
 
/* #define USE_LIBXMLCONTEXT */



Then if you look at xpath.c in contrib/xml2 you notice that it's doing
exactly the thing that the core module says it's unreliable: using
palloc and friends in xmlMemSetup.  So to fix the bug what's needed is
that the xmlMemSetup call in contrib is removed altogether, and all
memory is tracked and released by hand.  It's rather tedious, and it's
also difficult to plug all resulting memory leaks.  But AFAIUI doing
that would fix (some of?) the crashes.  Not sure if your crash is in
this category.

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


pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Streaming replication on win32, still broken
Next
From: Alvaro Herrera
Date:
Subject: Re: A thought: should we run pgindent now?