Skip site navigation (1) Skip section navigation (2)

Re: still memory leaks with libpgtcl

From: ljb <lbayuk(at)mindspring(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: still memory leaks with libpgtcl
Date: 2003-01-09 01:49:26
Message-ID: avikf6$2f0t$2@news.hub.org (view raw or flat)
Thread:
Lists: pgsql-interfaces
tgl(at)sss(dot)pgh(dot)pa(dot)us wrote:
> What we really need to do is reel in a Tcl guru to look at this.
> I think that there is a Tcl bug here somewhere; even if not, we seem
> to need someone who knows the Tcl library inside-and-out to tell us
> what we're doing wrong.
> 
> I don't have the time or interest to pursue this with the Tcl community,
> but perhaps one of you can do it?
> 
>> -#ifdef NOT_USED
>>  #if TCL_MAJOR_VERSION >= 8
>> -	if (connid->notifier_channel != NULL)
>> +	if (connid->notifier_channel != NULL && interp != NULL)
>>  		Tcl_UnregisterChannel(NULL, connid->notifier_channel);
>>  #endif
>> -#endif
> 
> Cool solution if it works --- but I'll not accept it unless someone can
> explain to me *why* it fixes the problem, and preferably just where in
> the Tcl documentation this is promised to be a correct solution...

It doesn't fix the problem; it avoids the problem.  The crash happens when
the DriverCloseProc calls UnregisterChannel on shutdown, not on a normal
disconnect. The leak happens when UnregisterChannel is not called on normal
disconnect. The patch avoids the issue by not calling UnregisterChannel if
interp is NULL, as it seems to be only if called during shutdown. So the
patch relies on undocumented behavior inside Tcl - that the
DriverCloseProc() is called with interp==NULL during shutdown.

I agree that something is wrong here, either with how Tcl implements the
unregister/shutdown, or with how libpgtcl uses channels. As I said before,
I don't recommend this patch be applied, except for people who have this
specific problem (long-running program doing frequent connect/disconnects).

In response to

Responses

pgsql-interfaces by date

Next:From: ljbDate: 2003-01-09 01:51:12
Subject: Re: still memory leaks with libpgtcl
Previous:From: ljbDate: 2003-01-09 01:38:50
Subject: Re: Shouldn't .pgpass work with anything which uses libpq?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group