Re: pltcl broken on tcl8.5 ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pltcl broken on tcl8.5 ?
Date: 2008-06-16 22:52:14
Message-ID: 8838.1213656734@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> Tom Lane wrote:
>> Hoo, nasty. Tcl_GetVar() is resetting interp->result.

> According to the manual page that's only supposed to happen if the
> TCL_LEAVE_ERR_MSG flag is used:

> TCL_LEAVE_ERR_MSG
> If an error is returned and this bit is set in flags, then an
> error message will be left in the interpreters result, where it
> can be retrieved with Tcl_GetObjResult or Tcl_GetStringResult.
> If this flag bit isnt set then no error message is left and the
> interpreters result will not be modified.

But notice that they specify using Tcl_GetObjResult or
Tcl_GetStringResult, rather than touching the field directly.
I suspect they'd regard this as not-a-bug. In any case I found
the responsible code: Tcl_SaveInterpState/Tcl_RestoreInterpState
restore the result as an object not a string. I see no such
routines in 8.4.

As I look at this, I think it's got even more problems: it's assuming
that interp->result is in the database encoding, which seems a pretty
faulty assumption considering it came from Tcl. pltcl_elog converts
to the database encoding before calling Tcl_SetResult, which makes
that path all right as long as Tcl doesn't do anything with the string
before exiting, but I don't particularly trust that assumption either.
All in all this is really quite broken.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2008-06-17 00:28:28 Re: TODO Item: Allow pg_hba.conf to specify host names along with IP addresses
Previous Message Andrew Dunstan 2008-06-16 22:00:33 Re: Crash in pgCrypto?