MySQL Server 4.1.1 alpha
MyODBC Connector: 3.51.08

Hello all,

I am experiencing the following problem: I have an dialog-based MFC app using the 
CDatabase class to connect to a MySQL DB using ODBC. My connection string specifies a 
DSN with the connection information. Additionally, this is a Unicode compilation ( 
Project Properties > General > Use Unicode Character Set ). My test app has a 
CWinThread-derived class named CDBThread, with a CDatabase member. 
CDBThread::InitInstance() calls OpenEx() for the CDatabase member. So far so good.

For the app's InitInstance, all I do is call AfxBeginThread() twice, to create two 
threads of type CDBThread. The application crashes when the db thread tries to connect 
to the db.

However, there are two things I can do to avoid the crash:

- Start only ONE CDBThread instead of TWO.
- Compile using multi-byte character set instead of Unicode.

Of course, these are both unnaceptable solutions. But it seems the problem is related 
only to multi-threaded apps using Unicode. Each CDBThread has its own CDatabase 
object, so no additional synchronization should be needed as two separate db 
connections should be created, right?

Oh, yeah, I tried replacing the MySQL db with an MS Access db and the problem went 
away. Any ideas? Is this a bug?

Here's the stack at the time of the crash:

        odbc32.dll!1f7b7e08()   
        odbc32.dll!1f7b8cd1()   
        odbc32.dll!1f7c59b8()   
        odbc32.dll!1f7a2f84()   
        odbc32.dll!1f7a2cb8()   
        msvcrt.dll!___updatetlocinfo()  + 0x40  
        [EMAIL PROTECTED]()  + 0x67     
        [EMAIL PROTECTED]()  + 0xb      
        [EMAIL PROTECTED]()  + 0xa      
        [EMAIL PROTECTED]()  + 0x2bf    
        [EMAIL PROTECTED]()  + 0x1a250  
        [EMAIL PROTECTED]()  + 0x8f4    
        [EMAIL PROTECTED]()  + 0x144    
        [EMAIL PROTECTED]()  + 0x3c     
>       mfc71ud.dll!CWnd::GetActiveWindow()  Line 193 + 0xf     C++



// From my db thread class:
BOOL CDBThread::InitInstance()
{

        m_db.OpenEx( _T( "ODBC;DRIVER=MySQL ODBC 3.51 Driver;DSN=dbtest;" ) );
        return TRUE;
}


// From the main app:
BOOL CDbtestApp::InitInstance()
{
        // (...) MFC wizard stuff here

        m_Thread[ 0 ] = AfxBeginThread( RUNTIME_CLASS( CDBThread ) );
        m_Thread[ 1 ] = AfxBeginThread( RUNTIME_CLASS( CDBThread ) ); // Comment this 
out = no crash

        // (...) more MFC wizard stuff here
}


Thank you,

Silvio Lopes de Oliveira
Software Engineer




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to