pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ljb <lbayuk@mindspring.com>
To: pgsql-interfaces@postgresql.org
Subject: Re: still memory leaks with libpgtcl
Date: Thu, 9 Jan 2003 01:49:26 +0000 (UTC)
Message-ID: <avikf6$2f0t$2@news.hub.org> (raw)
References: <785.1041999818@sss.pgh.pa.us>

tgl@sss.pgh.pa.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).



view thread (15+ messages)  latest in thread

Message-ID: <avikf6$2f0t$2@news.hub.org>
Permalink:  ../avikf6$2f0t$2@news.hub.org/
Also on:    postgresql.org/message-id/avikf6$2f0t$2@news.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: lbayuk@mindspring.com
  Subject: Re: still memory leaks with libpgtcl
  In-Reply-To: <avikf6$2f0t$2@news.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox