Re: plpython crash on exception

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Marko Kreen <markokr(at)gmail(dot)com>, Postgres Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: plpython crash on exception
Date: 2007-11-22 18:29:21
Message-ID: 20071122182921.GK4903@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane escribió:
> "Marko Kreen" <markokr(at)gmail(dot)com> writes:
> > Following function crashes plpython on x86-64 / gcc 4.1.2 / debian 4.0:
> > CREATE FUNCTION crashme(str_len integer)
> > RETURNS text AS $$
> > raise Exception("X" * str_len)
> > $$ LANGUAGE plpythonu;
>
> > SELECT crashme(1000);
>
> > Problem turns out to be va_list handling in PLy_vprintf() which
> > uses same va_list repeatedly. Fix is to va_copy to temp variable.
>
> This patch isn't acceptable because va_copy() isn't portable.
>
> I'm kinda wondering why PLy_printf and the functions after it even
> exist. They look like rather poorly done reimplementations of
> functionality that exists elsewhere in the backend (eg, stringinfo.c).
> In particular, why malloc and not palloc?

See attached patch.

I didn't bother to change the PLy_malloc and friends because I think
that would be too much change for 8.3. PLy_realloc is gone though
because there are no callers left after this patch.

--
Alvaro Herrera http://www.flickr.com/photos/alvherre/
"Ninguna manada de bestias tiene una voz tan horrible como la humana" (Orual)

Attachment Content-Type Size
plpython-elog.patch text/x-diff 4.3 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2007-11-22 18:33:16 Re: plpython crash on exception
Previous Message Tom Lane 2007-11-22 16:24:37 Re: plpython crash on exception