pgsql: Free libxml2/libxslt resources in a safer order.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Free libxml2/libxslt resources in a safer order.
Date: 2014-11-27 16:13:41
Message-ID: E1Xu1hN-0002X5-0G@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Free libxml2/libxslt resources in a safer order.

Mark Simonetti reported that libxslt sometimes crashes for him, and that
swapping xslt_process's object-freeing calls around to do them in reverse
order of creation seemed to fix it. I've not reproduced the crash, but
valgrind clearly shows a reference to already-freed memory, which is
consistent with the idea that shutdown of the xsltTransformContext is
trying to reference the already-freed stylesheet or input document.
With this patch, valgrind is no longer unhappy.

I have an inquiry in to see if this is a libxslt bug or if we're just
abusing the library; but even if it's a library bug, we'd want to adjust
our code so it doesn't fail with unpatched libraries.

Back-patch to all supported branches, because we've been doing this in
the wrong(?) order for a long time.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/6a694bbab20395603d751c9575746a753678aa5c

Modified Files
--------------
contrib/xml2/xslt_proc.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2014-11-27 17:14:33 pgsql: Mark response messages for translation in pg_isready.
Previous Message Tom Lane 2014-11-27 16:13:40 pgsql: Free libxml2/libxslt resources in a safer order.