4 messages in com.mysql.lists.plusplusmysql++ Not catching an exception aft...
FromSent OnAttachments
Jason Kushmaul26 Jun 2002 10:34 
Richard Fox27 Jun 2002 06:22 
Jason Kushmaul27 Jun 2002 08:02 
Jason Kushmaul27 Jun 2002 09:02 
Subject:mysql++ Not catching an exception after losing a connection.
From:Jason Kushmaul (jkus@wirelessdeveloper.com)
Date:06/26/2002 10:34:11 AM
List:com.mysql.lists.plusplus

I ran gdb and a backtrace to find the problem, all gdb output and code it refernces is shown below. I realize the below shows that I am using threads, however, within my thread I instantiate a Connection, and it is contained in that thread, no other thread process can even touch it or knows about it, so that should not be the problem in this situation.

The only two things I can think of, is I should catch{} a different Error object than what I already have. (I show these at the bottom of this message). But, one of my threads catches the disconnect. Please read on about my threading structure before flaming about threads.

Any ideas would be greatly appreciated.

Gdb output

------------------------------ (gdb) run Starting program: /path/to/program [New Thread 1024 (LWP 1176)] Main - Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Main - Error: Access denied for user: 'myuser@localhost' (Using password: YES) main() -Not Found: Starting oper: 7 [XXX I know mysql connected because this number is the result of a query...] [New Thread 2049 (LWP 1238)] [New Thread 1026 (LWP 1239)] Delayed SIGSTOP caught for LWP 1239. main() -Not Found: Starting oper: 8 [XXX same here] startOperation() - Starting up [New Thread 2051 (LWP 1240)] Delayed SIGSTOP caught for LWP 1240. Last message repeated 1 times there are no attachments startOperation() - Loading attachment there are attachments: startOperation() - Error: Lost connection to MySQL server during query [ XXX See, this thread catches the disconnect] startOperation() - Exiting, freeing resources [XXX same thread] startOperation() - Attempting to close dbConn [XXX same thread] startOperation() - Done exiting [XXX same thread] LWP 1240 exited. [XXX same thread actually exited]

Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 1026 (LWP 1239)] [XXX as you can see, different thread] 0x402ec237 in mysql_num_rows () from /usr/local/mysql/lib/mysql/libmysqlclient.so.11 (gdb) bt #0 0x402ec237 in mysql_num_rows () from /usr/local/mysql/lib/mysql/libmysqlclient.so.11 #1 0x0805edf2 in MysqlRes::size (this=0xbf7ff5dc) at /usr/local/include/result1.hh:180 #2 0x0805c82b in const_subscript_container::end ( this=0xbf7ff5fc) at /usr/local/include/resiter1.hh:44 #3 0x080535dd in startOperation (arg=0x8072ef8) at main.cpp:769 [XXX More below] #4 0x40068c84 in pthread_start_thread_event (arg=0xbf7ffc00) at manager.c:274 (gdb)

---------------------------------------------------------------------------------------

The first thing that is weird, is the second error, but this is not my problem and I do not want to vere off what my real problem is, but...

---------------- Main - Error: Access denied for user: 'broadcastinfo@localhost' (Using password: YES)

--------------- This shows up whether I have mysql started at execution time, or not and only when in gdb. thats funny, because for the rest of the code to operate, it has to have opened a successfull connection. I don't care about this, this only happens when I throw it into Gdb. I can connect to localhost with mysql client fine. I even gave the user@localhost ALL PRIVILEGS ON *.*. Anyways, on to my real problem:

Just to clear things up, the first error, shown below, is because I didn't have mysql started when I started the program, the second error above is immediatly when I started the program. this should obviously appear in this scenario, so disregard)

----------- Main - Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

-------------

Program received signal SIGSEGV, Segmentation fault. The point in my code at which mysql++ takes over, it is wrapped in Try{ ... } Catch{ ... } statements, but does not seem to catch the disconnect. (One threaded process does, as you can see before the SIGSEGV)

try catch code , with other stuff cut out

------------------------------------------------ main.cpp startOperation() { try{ bQuery=dbConn.query(); res=bQuery.store(); for (i=res.begin();i!=res.end();i++){

/**above is line 769, which is the last line in my code that runs until the SIGSEGV**/ bjs=*i; .... } } catch(BadQuery er){ } catch(BadConversion er){ } }

-----------------------------

--

__________________________________ Jason Kushmaul, Software Engineer WirelessDeveloper.com Suite 200 2875 Northwind Drive East Lansing, MI 48823 +1 517-337-2701 x 205

jkus@WirelessDeveloper.com PGP Public key available at http://www.keyserver.net/

Become a Member Today!! http://www.WirelessDeveloper.com

--

__________________________________ Jason Kushmaul, Software Engineer WirelessDeveloper.com Suite 200 2875 Northwind Drive East Lansing, MI 48823 +1 517-337-2701 x 205

jkushmaul@WirelessDeveloper.comhttp://www.keyserver.net/http://www.WirelessDeveloper.com PGP Public key available at

Become a Member Today!!

Become a Member Today!! http://www.WirelessDeveloper.com