Re: remove contrib/xml2

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: remove contrib/xml2
Дата
Msg-id 20100218140945.GA6317@alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: remove contrib/xml2  (M Z <jm80008@gmail.com>)
Ответы Re: remove contrib/xml2  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Streaming replication on win32, still broken
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: A thought: should we run pgindent now?