pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
EN_Destructor bug?
4+ messages / 4 participants
[nested] [flat]

* EN_Destructor bug?
@ 2005-10-19 14:07 Tom Hughes <thh@cyberscience.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Hughes @ 2005-10-19 14:07 UTC (permalink / raw)
  To: pgsql-odbc

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/

Attachments:

psqlodbc-environ.patch (text/x-patch, 1.2K) download ? .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);
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: EN_Destructor bug?
@ 2005-10-25 07:39 Dave Page <dpage@vale-housing.co.uk>
  0 siblings, 0 replies; 4+ messages in thread

From: Dave Page @ 2005-10-25 07:39 UTC (permalink / raw)
  To: Tom Hughes <thh@cyberscience.com>; pgsql-odbc

Thanks Tom, patch applied.

Regards, Dave 

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org 
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Tom Hughes
> Sent: 19 October 2005 15:07
> To: pgsql-odbc@postgresql.org
> Subject: [ODBC] EN_Destructor bug?
> 
> 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/
> 
> 



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* EN_Destructor bug
@ 2013-01-22 13:32 mkocherov <mkocherov@parallels.com>
  2013-01-23 23:42 ` Re: EN_Destructor bug Inoue, Hiroshi <inoue@tpf.co.jp>
  0 siblings, 1 reply; 4+ messages in thread

From: mkocherov @ 2013-01-22 13:32 UTC (permalink / raw)
  To: pgsql-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 ^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: EN_Destructor bug
  2013-01-22 13:32 EN_Destructor bug mkocherov <mkocherov@parallels.com>
@ 2013-01-23 23:42 ` Inoue, Hiroshi <inoue@tpf.co.jp>
  0 siblings, 0 replies; 4+ messages in thread

From: Inoue, Hiroshi @ 2013-01-23 23:42 UTC (permalink / raw)
  To: mkocherov <mkocherov@parallels.com>; +Cc: pgsql-odbc

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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2013-01-23 23:42 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-19 14:07 EN_Destructor bug? Tom Hughes <thh@cyberscience.com>
2005-10-25 07:39 Re: EN_Destructor bug? Dave Page <dpage@vale-housing.co.uk>
2013-01-22 13:32 EN_Destructor bug mkocherov <mkocherov@parallels.com>
2013-01-23 23:42 ` Re: EN_Destructor bug Inoue, Hiroshi <inoue@tpf.co.jp>

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