Re: memory leak in xml2 contrib module

Lists: pgsql-bugs
From: tv(at)fuzzy(dot)cz
To: pgsql-bugs(at)postgresql(dot)org
Subject: memory leak in xml2 contrib module
Date: 2010-11-26 12:54:19
Message-ID: d7a03755ddcb11e5ffca891bbf7aa33d.squirrel@sq.gransy.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Hi,

one of my colleagues found ugly memory leak in the xml2 contrib module.
Try this:

select xpath_number('<data>' || generate_series || '</data>','/data') from
generate_series(1,500000);

This will allocate arbitrary amount of memory, and it won't release it
until the backend exits (user disconnects). We've found this in 8.4 and
I've verified it's still present in 9.0.1.

I know the xml2 module is deprecated and most of the functions was moved
into core (and behave correctly) but xslt_process function was not and
that's why xml2 module is used.

Pavel Stehule already prepared a fix (see the attachment).

regards
Tomas

Attachment Content-Type Size
xml2memleakfix.diff / 1.6 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: tv(at)fuzzy(dot)cz
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: memory leak in xml2 contrib module
Date: 2010-12-14 20:50:36
Message-ID: AANLkTi=1sG8=UuAUyD-8LoyDNZYXOdcNfn2NMsmGV7G_@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Fri, Nov 26, 2010 at 7:54 AM, <tv(at)fuzzy(dot)cz> wrote:
> one of my colleagues found ugly memory leak in the xml2 contrib module.
> Try this:
>
> select xpath_number('<data>' || generate_series || '</data>','/data') from
> generate_series(1,500000);
>
> This will allocate arbitrary amount of memory, and it won't release it
> until the backend exits (user disconnects). We've found this in 8.4 and
> I've verified it's still present in 9.0.1.
>
> I know the xml2 module is deprecated and most of the functions was moved
> into core (and behave correctly) but xslt_process function was not and
> that's why xml2 module is used.
>
> Pavel Stehule already prepared a fix (see the attachment).

I don't see a response to this email, but it looks like Tom did apply a fix.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Tomas Vondra <tv(at)fuzzy(dot)cz>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: memory leak in xml2 contrib module
Date: 2010-12-14 20:57:31
Message-ID: 4D07DA3B.3070402@fuzzy.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Dne 14.12.2010 21:50, Robert Haas napsal(a):
> On Fri, Nov 26, 2010 at 7:54 AM, <tv(at)fuzzy(dot)cz> wrote:
>> one of my colleagues found ugly memory leak in the xml2 contrib module.
>> Try this:
>>
>> select xpath_number('<data>' || generate_series || '</data>','/data') from
>> generate_series(1,500000);
>>
>> This will allocate arbitrary amount of memory, and it won't release it
>> until the backend exits (user disconnects). We've found this in 8.4 and
>> I've verified it's still present in 9.0.1.
>>
>> I know the xml2 module is deprecated and most of the functions was moved
>> into core (and behave correctly) but xslt_process function was not and
>> that's why xml2 module is used.
>>
>> Pavel Stehule already prepared a fix (see the attachment).
>
> I don't see a response to this email, but it looks like Tom did apply a fix.

Yes, AFAIK there's a relevant discussion in the pgsql-hackers list.

regards
Tomas