dbTalk Databases Forums  

Destructor of the Connection fails

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Destructor of the Connection fails in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Destructor of the Connection fails - 06-15-2006 , 04:17 PM







Hi,

I have the following code:

int main(int argc, char *argv[])
{
=09
Connection con(use_exceptions);
con.connect(/*put parameters here*/);
Query query =3D con.query();
=20
cout << "Exiting.." << endl;
=20
return 0;
}

After "Exiting.." is printed the program causes segmentation fault. I=20
think this means that destructor of either Connection or Query fails. Do=20
I handle objects con and query in improper way or is there a bug in=20
mysql++?

I have MySQL 5.0.20, mysql++ 2.1.1 and GCC 3.4.5 on Red Hat Linux.


Regards,

-Matti

__
Saunalahti Xtra - Uusi GSM-vuokrapuhelin ja edistykselliset Xtra-palvelut k=
=E4ytt=F6=F6si alk. 4,95 e/kk! http://saunalahti.fi/xtra/


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default Re: Destructor of the Connection fails - 06-16-2006 , 03:18 AM







Hi again,

I simplified things a bit more. Now i have the following code (without=20
any Query object):

int main(int argc, char *argv[])
{
Connection con(use_exceptions);
con.connect(/*parameters here..*/);
if(!con.connected())
{
cout << "Can't connect!" << endl;
return 1;
}
=20
cout << "Closing connection.." << endl;
con.close();
cout << "Exiting.." << endl;
=20
return 0;
}

It crashes in the line "con.close()". GDB tells me the following story:

Program received signal SIGSEGV, Segmentation fault.
0x00000039d1068b85 in free () from /lib64/tls/libc.so.6

If I have only the following code, it works fine.

int main(int argc, char *argv[])
{
Connection con(use_exceptions);
cout << "Exiting.." << endl;
return 0;
}

But every time I connect to the database something goes wrong when I am=20
closing the connection (or destructing the Connection object).

What should I do?

Regards,

-Matti

=20
Quote:
Hi,
=20
I have the following code:
=20
int main(int argc, char *argv[])
{
=09
Connection con(use_exceptions);
con.connect(/*put parameters here*/);
Query query =3D con.query();
=20
cout << "Exiting.." << endl;
=20
return 0;
}
=20
After "Exiting.." is printed the program causes segmentation fault. I=20
think this means that destructor of either Connection or Query fails. Do=
=20
I handle objects con and query in improper way or is there a bug in=20
mysql++?
=20
I have MySQL 5.0.20, mysql++ 2.1.1 and GCC 3.4.5 on Red Hat Linux.
=20
=20
Regards,
=20
-Matti
=20
__
Saunalahti Xtra - Uusi GSM-vuokrapuhelin ja edistykselliset Xtra-palvelut k=
=E4ytt=F6=F6si alk. 4,95 e/kk! http://saunalahti.fi/xtra/


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: Destructor of the Connection fails - 06-16-2006 , 09:11 PM



mazah_82 (AT) jippii (DOT) fi wrote:
Quote:
It crashes in the line "con.close()". GDB tells me the following story:

Program received signal SIGSEGV, Segmentation fault.
0x00000039d1068b85 in free () from /lib64/tls/libc.so.6
You're going to have to debug it more deeply than that to tell anyone
something useful. At the very least, we need a backtrace.

Try this modified program instead:



#include <mysql++.h>
#include <iostream>

using namespace std;
using namespace mysqlpp;

int
main(int argc, char *argv[])
{
try {
Connection con(use_exceptions);
con.connect("db", "localhost", "user, "pass");
if (!con.connected()) {
cout << "Can't connect!" << endl;
return 1;
}
cout << "Closing connection.." << endl;
con.close();
cout << "Exiting.." << endl;
}
catch (exception& e) {
cout << "Exception caught: " << e.what() << endl;
}

return 0;
}


Notice how it catches exceptions. Your symptom could just be caused by
an uncaught exception.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: Destructor of the Connection fails - 06-19-2006 , 03:07 AM




Hi,

The problem wasn't caused by uncaught exceptions.

With the code you cave me I ran gdb and made backtrace with option=20
'full' after the segmentation fault. Here is the result:

(gdb) bt full
#0 0x00000039d1068b85 in free () from /lib64/tls/libc.so.6
No symbol table info available.
#1 0x0000002a956d755e in my_no_flags_free () from=20
/usr/lib64/libmysqlclient.so.15
No symbol table info available.
#2 0x0000002a956f9b60 in mysql_select_db () from=20
/usr/lib64/libmysqlclient.so.15
No symbol table info available.
#3 0x0000002a956f9bfc in mysql_close () from /usr/lib64/libmysqlclient.so.=
15
No symbol table info available.
#4 0x00000000004010f5 in mysqlpp::Connection::close (this=3D0x7fbffff350)=
=20
at /usr/lib/mysql++-2.1.1/lib/connection.h:171
No locals.
#5 0x0000000000400f34 in main (argc=3D1, argv=3D0x7fbffff9a8) at test2.cpp=
:23
con =3D {<mysqlpp::OptionalExceptions> =3D {_vptr.OptionalExceptions =3D=20
0x2a95692870,
exceptions_ =3D true}, <mysqlpp::Lockable> =3D {_vptr.Lockable =3D 0x2a9569=
2890,=20
pimpl_ =3D 0x502790},
mysql_ =3D {net =3D {vio =3D 0x0, buff =3D 0x0, buff_end =3D 0x509d00 " a",
write_pos =3D 0x507d00 "\001",
read_pos =3D 0x507d00 "\001",
fd =3D 6,
max_packet =3D 8192,=20
max_packet_size =3D 1073741824,
pkt_nr =3D 1,
compress_pkt_nr =3D 0,
write_timeout =3D 31536000,
read_timeout =3D 31536000,
retry_count =3D 1,
fcntl =3D 0,
compress =3D 0 '\0',=20
remain_in_buf =3D 0,
length =3D 0,
buf_length =3D 0,
where_b =3D 0,
return_status =3D 0x0,
reading_or_writing =3D 0 '\0',
save_char =3D 0 '\0',
no_send_ok =3D 0 '\0',=20
no_send_eof =3D 0 '\0',
no_send_error =3D 0 '\0',
last_error =3D '\0' <repeats 511 times>,
sqlstate =3D "00000",
last_errno =3D 0,
error =3D 0 '\0',
query_cache_query =3D 0x0,=20
report_error =3D 0 '\0',
return_errno =3D 0 '\0'},
connector_fd =3D 0x0,
host =3D 0x502fb0 "localhost",
user =3D 0x503020 "`/P",
passwd =3D 0x503040 "",=20
unix_socket =3D 0x502fc0 "/var/lib/mysql/mysql.sock", server_version =3D=20
0x502fe0 "5.0.20-standard",
host_info =3D 0x502f90 "=E0;P",
info =3D 0x0,
db =3D 0x510d10 "\0200P",
charset =3D 0x2a9580d840,
fields =3D 0x0,
field_alloc =3D {free =3D 0x0, used =3D 0x0, pre_alloc =3D 0x0, min_malloc =
=3D 32,=20
block_size =3D 8160, block_num =3D 4, first_block_usage =3D 0, error_handle=
r =3D=20
0},
affected_rows =3D 18446744073709551615,
insert_id =3D 0,
extra_info =3D 0,
thread_id =3D 80,
packet_length =3D 7,
port =3D 0,
client_flag =3D 41613,=20
server_capabilities =3D 41516,
protocol_version =3D 10,
field_count =3D 0,
server_status =3D 2,
server_language =3D 8,
warning_count =3D 0,
options =3D {connect_timeout =3D 0, read_timeout =3D 0, write_timeout =3D 0=
,=20
port =3D 0, protocol =3D 0, client_flag =3D 0, host =3D 0x0, user =3D 0x0,=
=20
password =3D 0x0, unix_socket =3D 0x0, db =3D 0x0, init_commands =3D 0x0,=
=20
my_cnf_file =3D 0x0, my_cnf_group =3D 0x0, charset_dir =3D 0x0, charset_nam=
e =3D=20
0x0, ssl_key =3D 0x0, ssl_cert =3D 0x0, ssl_ca =3D 0x0, ssl_capath =3D 0x0,=
=20
ssl_cipher =3D 0x0, shared_memory_base_name =3D 0x0, max_allowed_packet =3D=
0,=20
use_ssl =3D 0 '\0', compress =3D 0 '\0', named_pipe =3D 0 '\0', rpl_probe =
=3D 0=20
'\0', rpl_parse =3D 0 '\0', no_master_reads =3D 0 '\0', separate_thread =3D=
0=20
'\0', methods_to_use =3D MYSQL_OPT_CONNECT_TIMEOUT, client_ip =3D 0x0,=20
secure_auth =3D 0 '\0', report_data_truncation =3D 0 '\0', local_infile_ini=
t=20
=3D 0, local_infile_read =3D 0, local_infile_end =3D 0, local_infile_error =
=3D=20
0, local_infile_userdata =3D 0x0},

status =3D MYSQL_STATUS_READY,
free_me =3D 0 '\0',=20
reconnect =3D 0 '\0',
scramble =3D "V_[*]uU,w5B-VJQ8eq*{",
rpl_pivot =3D 1 '\001',
master =3D 0x7fbffff370,
next_slave =3D 0x7fbffff370,
last_used_slave =3D 0x0,=20
last_used_con =3D 0x7fbffff370,
stmts =3D 0x0,
methods =3D 0x2a9590ce20,
thd =3D 0x0,
unbuffered_fetch_owner =3D 0x0},
is_connected_ =3D true,
connecting_ =3D false,
success_ =3D true,=20
pending_options_ =3D=20
{<std::_Deque_base<mysqlpp::Connection::OptionInfo ,std::allocator<mysqlpp::=
Connection::OptionInfo>=20
Quote:
=3D {_M_impl =3D {<std::allocator<mysqlpp::Connection::OptionInfo>> =3D=
=20
{<__gnu_cxx::new_allocator<mysqlpp::Connection::Op tionInfo>> =3D {<No data=
=20
fields>}, <No data fields>}, _M_map =3D 0x5027b0, _M_map_size =3D 8,=20
_M_start =3D {_M_cur =3D 0x502800, _M_first =3D 0x502800, _M_last =3D 0x502=
9f8,=20
_M_node =3D 0x5027c8}, _M_finish =3D {_M_cur =3D 0x502800, _M_first =3D=20
0x502800, _M_last =3D 0x5029f8, _M_node =3D 0x5027c8}}}, <No data fields>},
static legal_opt_arg_types_ =3D {mysqlpp::Connection:pt_type_integer,=20
mysqlpp::Connection:pt_type_none, mysqlpp::Connection:pt_type_none,=20
mysqlpp::Connection:pt_type_string,=20
mysqlpp::Connection:pt_type_string,=20
mysqlpp::Connection:pt_type_string,=20
mysqlpp::Connection:pt_type_string,=20
mysqlpp::Connection:pt_type_string,=20
mysqlpp::Connection:pt_type_integer,
mysqlpp::Connection:pt_type_integer,=20
mysqlpp::Connection:pt_type_string,=20
mysqlpp::Connection:pt_type_integer,=20
mysqlpp::Connection:pt_type_integer,=20
mysqlpp::Connection:pt_type_none, mysqlpp::Connection:pt_type_none,=20
mysqlpp::Connection:pt_type_none, mysqlpp::Connection:pt_type_none,=20
mysqlpp::Connection:pt_type_string,=20
mysqlpp::Connection:pt_type_boolean,=20
mysqlpp::Connection:pt_type_boolean,=20
mysqlpp::Connection:pt_type_boolean,=20
mysqlpp::Connection:pt_type_boolean}}


-Matti


Quote:
mazah_82 (AT) jippii (DOT) fi wrote:
=20
It crashes in the line "con.close()". GDB tells me the following story:
=20
Program received signal SIGSEGV, Segmentation fault.
0x00000039d1068b85 in free () from /lib64/tls/libc.so.6
=20
You're going to have to debug it more deeply than that to tell anyone=20
something useful. At the very least, we need a backtrace.
=20
Try this modified program instead:
=20
=20
=20
#include <mysql++.h
#include <iostream
=20
using namespace std;
using namespace mysqlpp;
=20
int
main(int argc, char *argv[])
{
try {
Connection con(use_exceptions);
con.connect("db", "localhost", "user, "pass");
if (!con.connected()) {
cout << "Can't connect!" << endl;
return 1;
}
cout << "Closing connection.." << endl;
con.close();
cout << "Exiting.." << endl;
}
catch (exception& e) {
cout << "Exception caught: " << e.what() << endl;
}
=20
return 0;
}
=20
=20
Notice how it catches exceptions. Your symptom could just be caused by=
=20
an uncaught exception.
=20
__
Saunalahti Xtra - Uusi GSM-vuokrapuhelin ja edistykselliset Xtra-palvelut k=
=E4ytt=F6=F6si alk. 4,95 e/kk! http://saunalahti.fi/xtra/


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #5  
Old   
AT
 
Posts: n/a

Default Re: Destructor of the Connection fails - 06-19-2006 , 10:44 AM



mazah_82 (AT) jippii (DOT) fi wrote:
Quote:
With the code you cave me I ran gdb and made backtrace with option
'full' after the segmentation fault. Here is the result:

(gdb) bt full
#0 0x00000039d1068b85 in free () from /lib64/tls/libc.so.6
No symbol table info available.
#1 0x0000002a956d755e in my_no_flags_free () from
/usr/lib64/libmysqlclient.so.15
As you can see, it's barfing down in libc, via libmysqlclient. It's
quite possible that MySQL++ isn't at fault here. The program I sent you
doesn't crash here on our i386 boxen. As a result, it's going to be up
to you to find out where the problem is; again, it could just be that
MySQL++ is tickling a bug that's elsewhere in the system.

It seems you're running one of the transitional x64 systems. Such
systems often aren't as fully debugged as more stable systems, like i386
and the old guard of 64-bit systems.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.