Re: PLTCL return_null crash...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>, pgsql-general(at)postgresql(dot)org
Subject: Re: PLTCL return_null crash...
Date: 2002-10-08 13:39:24
Message-ID: 1375.1034084364@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Joe Conway <mail(at)joeconway(dot)com> writes:
> Any idea wht I can't step through this? In any case, the problem seems to be
> in this section of code:

> <snip>
> if (SPI_finish() != SPI_OK_FINISH)
> elog(ERROR, "pltcl: SPI_finish() failed");

> UTF_BEGIN;
> if (fcinfo->isnull)
> retval = (Datum) 0;
> else
> retval = FunctionCall3(&prodesc->result_in_func,
> PointerGetDatum(UTF_U2E(interp->result)),
> ObjectIdGetDatum(prodesc->result_in_elem),
> Int32GetDatum(-1));
> UTF_END;
> </snip>

Oh, but of course: if you are returning NULL then this sequence fails
because it pfrees an uninitialized pointer. It's fixed in CVS tip,
where the sequence reads like

if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "pltcl: SPI_finish() failed");

if (fcinfo->isnull)
retval = (Datum) 0;
else
{
UTF_BEGIN;
retval = FunctionCall3(&prodesc->result_in_func,
PointerGetDatum(UTF_U2E(interp->result)),
ObjectIdGetDatum(prodesc->result_in_elem),
Int32GetDatum(-1));
UTF_END;
}

The reason I failed to duplicate it here was I didn't compile with
--enable-multibyte. The bug is definitely still there in 7.2.3 if
you use multibyte.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert Treat 2002-10-08 13:40:44 Re: Hot Backup
Previous Message Elielson Fontanezi 2002-10-08 13:35:55 pg_dump command inside shell scripts