pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: markw <markw@mohawksoft.com>
To: pgsql-odbc@postgresql.org
Subject: Threading crash using ODBC
Date: Fri, 15 Nov 2002 11:21:58 -0500
Message-ID: <3DD51F26.7050201@mohawksoft.com> (raw)

Here's what  I have:

I have an application with 1 main thread and a number of worker threads.
At startup, I allocate a number of ODBC connections.
I have an internal queue that is protected by a mutex.
When one of the worker threads wants to use the database, it gets an un 
occupied SQL connection from the queue.

At startup, I can execte a query just fine. When I try to execute a 
query from one of the worker threads, I get a core dump.

I am using UNIX ODBC and the PostgreSQL driver, as shipped with RedHat 7.3.

The stack trace looks like this:

0  0x402fba4c in CC_send_query () from /usr/lib/libodbcpsql.so
(gdb) where
#0  0x402fba4c in CC_send_query () from /usr/lib/libodbcpsql.so
#1  0x40314842 in SC_execute () from /usr/lib/libodbcpsql.so
#2  0x40304c45 in PG_SQLExecute () from /usr/lib/libodbcpsql.so
#3  0x40304c6b in SQLExecute () from /usr/lib/libodbcpsql.so
#4  0x402a13f4 in SQLExecute () from /usr/lib/libodbc.so.1
#5  0x40023d6f in MSqlODBC::ExecResult (this=0x806bfd4,
    sql=0x4037f83c "select value, timeout from msession_sessions where 
session = '2b7atuahma6u9igcorr7c6q8ld7ne86o'") at modbcsql.cpp:360


The ExecResult function looks like this:

SQLRESULT MSqlODBC::ExecResult(char *sql)
{
        TRACE_FUNCT("ExecResult");
        unsigned long err;
        HSTMT hstmt;

        TRACE_STR(sql);

        err = SQLAllocStmt(m_hdbc, &hstmt);

        if(err != SQL_SUCCESS)
        {
                fprintf(stderr, "Could not get Stmt\n");
                return NULL;
        }

        err = SQLPrepare(hstmt, (SQLCHAR *)sql, SQL_NTS);

        if(err != SQL_SUCCESS)
        {
                fprintf(stderr, "Could not Prepare Statement [%s]\n", sql);
                return NULL;
        }

        err = SQLExecute(hstmt);

        if(err != SQL_SUCCESS)
        {
                fprintf(stderr, "Could not ExecDirect\n");
                SQLFreeStmt(hstmt, SQL_DROP);
                hstmt = NULL;
        }
        return (SQLRESULT)build_result(hstmt);
}





view thread (8+ messages)  latest in thread

Message-ID: <3DD51F26.7050201@mohawksoft.com>
Permalink:  ../3DD51F26.7050201@mohawksoft.com/
Also on:    postgresql.org/message-id/3DD51F26.7050201@mohawksoft.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: markw@mohawksoft.com
  Subject: Re: Threading crash using ODBC
  In-Reply-To: <3DD51F26.7050201@mohawksoft.com>
  References: <3DD51F26.7050201@mohawksoft.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