Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ty9zZ-0000Ma-GS for pgsql-odbc@arkaria.postgresql.org; Wed, 23 Jan 2013 23:44:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Ty9zY-0002Li-My for pgsql-odbc@arkaria.postgresql.org; Wed, 23 Jan 2013 23:44:28 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ty9zX-0002Lc-Us for pgsql-odbc@postgresql.org; Wed, 23 Jan 2013 23:44:28 +0000 Received: from sd.tpf.co.jp ([210.161.239.34]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Ty9zU-0006bR-R5 for pgsql-odbc@postgresql.org; Wed, 23 Jan 2013 23:44:27 +0000 Received: (qmail 3246 invoked by uid 512); 23 Jan 2013 23:44:19 -0000 Received: from unknown (HELO ?127.0.0.1?) (100.126.1.62) by sd2.tpf-fw-c.co.jp with SMTP; 23 Jan 2013 23:44:19 -0000 Message-ID: <51007582.3010601@tpf.co.jp> Date: Thu, 24 Jan 2013 08:42:58 +0900 From: "Inoue, Hiroshi" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: mkocherov CC: pgsql-odbc@postgresql.org Subject: Re: EN_Destructor bug References: <1358861564828-5741621.post@n5.nabble.com> In-Reply-To: <1358861564828-5741621.post@n5.nabble.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org Thanks for the report. I would take care fo it. regards, Hiroshi Inoue (2013/01/22 22:32), mkocherov wrote: > Hello! > > 1) We observe crashes in psqlodbc.so library from time to time. Crash dumps > typically look like this one: > #0 0x0057f420 in __kernel_vsyscall () > #1 0x09ba7df0 in raise () from /lib/libc.so.6 > #2 0x09ba9701 in abort () from /lib/libc.so.6 > #3 0x09bdebcb in __libc_message () from /lib/libc.so.6 > #4 0x09be6fea in _int_free () from /lib/libc.so.6 > #5 0x09be7329 in free () from /lib/libc.so.6 > #6 0x02c601d0 in EN_Destructor () from /usr/pgsql-9.0/lib/psqlodbc.so > #7 0x02c60224 in PGAPI_FreeEnv () from /usr/pgsql-9.0/lib/psqlodbc.so > #8 0x02c8f3fe in SQLFreeHandle () from /usr/pgsql-9.0/lib/psqlodbc.so > #9 0x00e961e5 in ?? () from /usr/lib/libodbc.so.1 > #10 0x00e9666d in ?? () from /usr/lib/libodbc.so.1 > #11 0x00e96760 in ?? () from /usr/lib/libodbc.so.1 > #12 0x00e9d02e in SQLDisconnect () from /usr/lib/libodbc.so.1 > … > Due to nature of our program it makes frequent connect / disconnects in > parallel threads. ODBC threading level is set to 2, e.g.: > [PostgreSQL] > Description = PostgreSQL driver > Driver = /usr/pgsql-9.0/lib/psqlodbc.so > Setup = /usr/pgsql-9.0/lib/psqlodbc.so > FileUsage = 1 > Threading = 2 > 2) Checking code of driver reveals that it doesn’t protect shared connection > list when making cleanup tasks in EN_Destructor (PGAPI_FreeEnv -> > EN_Destructor). In this function there is no ENTER_CONNS_CS / > LEAVE_CONNS_CS; > 3) In 2005 Tom Hughes > (http://postgresql.1045698.n5.nabble.com/EN-Destructor-bug-td2187457.html) > provided patch that fixed this problem but then his changes were lost > (starting from psqlodbc-08.02.0100 version). > 4) The problem was reproduced on latest stock drivers psqlodbc-09.00.0310 > and psqlodbc-09.01.0200. > 5) When logging to mylog is enrolled then problem is hardly reproduced – it > seems parallels calls are effectively serialized within mylog() function. > 6) Problem is somewhat mitigated by the fact that default threading level in > unixODBC is set to 3 which eventually prevents races in psqlodbc driver. > 7) Patch: > --- environ.c.van 2010-08-21 10:29:19.000000000 +0400 > +++ environ.c 2013-01-17 18:47:12.000000000 +0300 > @@ -583,6 +583,7 @@ > */ > > /* Free any connections belonging to this environment */ > + ENTER_CONNS_CS; > for (lf = 0, nullcnt = 0; lf < conns_count; lf++) > { > if (NULL == conns[lf]) > @@ -603,6 +604,7 @@ > conns = NULL; > conns_count = 0; > } > + LEAVE_CONNS_CS; > DELETE_ENV_CS(self); > free(self); > > Thanks! > > Michael Kocherov > Software Developer > Parallels Automation Maintenance -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc