X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 08B3CDA2BB for ; Wed, 19 Oct 2005 11:07:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73678-02 for ; Wed, 19 Oct 2005 14:07:21 +0000 (GMT) Received: from gate.uk.cyberscience.com (gate.uk.cyberscience.com [213.38.135.130]) by svr1.postgresql.org (Postfix) with ESMTP id DA5A9D8391 for ; Wed, 19 Oct 2005 11:07:22 -0300 (ADT) Received: from elva.uk.cyberscience.com ([172.16.2.59]:33655) by gate.uk.cyberscience.com with esmtp (Exim 4.52) id 1ESEbG-00010Q-Pw for pgsql-odbc@postgresql.org; Wed, 19 Oct 2005 15:07:26 +0100 Received: from dellow.uk.cyberscience.com ([172.16.2.58]:43825) by elva.uk.cyberscience.com with esmtp (Exim 4.52) id 1ESEbD-0007y0-1j for pgsql-odbc@postgresql.org; Wed, 19 Oct 2005 15:07:26 +0100 Received: from thh by dellow.uk.cyberscience.com with local (Exim 4.54) id 1ESEbC-0003EC-WE for pgsql-odbc@postgresql.org; Wed, 19 Oct 2005 15:07:23 +0100 To: pgsql-odbc@postgresql.org Subject: EN_Destructor bug? From: Tom Hughes Organization: Cyberscience Corporation Date: Wed, 19 Oct 2005 15:07:22 +0100 Message-ID: User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200510/108 X-Sequence-Number: 6210 --=-=-= When EN_Destructor is called it searches through the connection array and destroys any connections which belong that environment. Unfortunately it doesn't NULL out the connection array entry afterwards so a future call to EN_Destructor can wind up trying to destroy that connection again if another environment has been allocated at the same address. Also, shouldn't EN_Destructor hold the CONNS critical section while it is playing with the connection array? The attached patch fixes both of these issues and seems to have fixed the crashes I was observing. Tom -- Tom Hughes (thh@cyberscience.com) Software Engineer, Cyberscience Corporation http://www.cyberscience.com/ --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=psqlodbc-environ.patch ? .deps ? .libs ? Makefile ? Makefile.in ? acinclude.m4 ? aclocal.m4 ? autom4te.cache ? bind.lo ? columninfo.lo ? config.h ? config.h.in ? config.log ? config.status ? configure ? connection.lo ? convert.lo ? depcomp ? descriptor.lo ? dlg_specific.lo ? drvconn.lo ? environ.lo ? execute.lo ? info.lo ? info30.lo ? install-sh ? libtool ? libtool.m4 ? misc.lo ? missing ? multibyte.lo ? odbcapi.lo ? odbcapi30.lo ? odbcapi30w.lo ? odbcapiw.lo ? options.lo ? parse.lo ? pgapi30.lo ? pgtypes.lo ? psqlodbc.la ? psqlodbc.lo ? qresult.lo ? results.lo ? stamp-h1 ? statement.lo ? tuple.lo ? tuplelist.lo ? win_md5.lo ? win_unicode.lo Index: environ.c =================================================================== RCS file: /cvsroot/psqlodbc/psqlodbc/environ.c,v retrieving revision 1.54 diff -u -r1.54 environ.c --- environ.c 4 Oct 2005 19:03:19 -0000 1.54 +++ environ.c 19 Oct 2005 14:04:06 -0000 @@ -723,11 +723,16 @@ */ /* Free any connections belonging to this environment */ + ENTER_CONNS_CS; for (lf = 0; lf < MAX_CONNECTIONS; lf++) { if (conns[lf] && conns[lf]->henv == self) + { rv = rv && CC_Destructor(conns[lf]); + conns[lf] = NULL; + } } + LEAVE_CONNS_CS; DELETE_ENV_CS(self); free(self); --=-=-=--