pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: mkocherov <mkocherov@parallels.com>
To: pgsql-odbc@postgresql.org
Subject: EN_Destructor bug
Date: Tue, 22 Jan 2013 05:32:44 -0800 (PST)
Message-ID: <1358861564828-5741621.post@n5.nabble.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>

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:
inline patch 1: environ.c (+2/-0 lines) download inline-1.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 -- View this message in context: http://postgresql.1045698.n5.nabble.com/EN-Destructor-bug-tp5741621.html Sent from the PostgreSQL - odbc mailing list archive at Nabble.com. -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc

view thread (4+ messages)  latest in thread

Message-ID: <1358861564828-5741621.post@n5.nabble.com>
Permalink:  ../1358861564828-5741621.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1358861564828-5741621.post@n5.nabble.com

 ·  · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: mkocherov@parallels.com
  Subject: Re: EN_Destructor bug
  In-Reply-To: <1358861564828-5741621.post@n5.nabble.com>
  References: <1358861564828-5741621.post@n5.nabble.com>

* 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