Hi,
The problem wasn't caused by uncaught exceptions.
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
No symbol table info available.
#2 0x0000002a956f9b60 in mysql_select_db () from
/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=0x7fbffff350)
at /usr/lib/mysql++-2.1.1/lib/connection.h:171
No locals.
#5 0x0000000000400f34 in main (argc=1, argv=0x7fbffff9a8) at test2.cpp:23
con = {<mysqlpp::OptionalExceptions> = {_vptr.OptionalExceptions =
0x2a95692870,
exceptions_ = true}, <mysqlpp::Lockable> = {_vptr.Lockable = 0x2a95692890,
pimpl_ = 0x502790},
mysql_ = {net = {vio = 0x0, buff = 0x0, buff_end = 0x509d00 " a",
write_pos = 0x507d00 "\001",
read_pos = 0x507d00 "\001",
fd = 6,
max_packet = 8192,
max_packet_size = 1073741824,
pkt_nr = 1,
compress_pkt_nr = 0,
write_timeout = 31536000,
read_timeout = 31536000,
retry_count = 1,
fcntl = 0,
compress = 0 '\0',
remain_in_buf = 0,
length = 0,
buf_length = 0,
where_b = 0,
return_status = 0x0,
reading_or_writing = 0 '\0',
save_char = 0 '\0',
no_send_ok = 0 '\0',
no_send_eof = 0 '\0',
no_send_error = 0 '\0',
last_error = '\0' <repeats 511 times>,
sqlstate = "00000",
last_errno = 0,
error = 0 '\0',
query_cache_query = 0x0,
report_error = 0 '\0',
return_errno = 0 '\0'},
connector_fd = 0x0,
host = 0x502fb0 "localhost",
user = 0x503020 "`/P",
passwd = 0x503040 "",
unix_socket = 0x502fc0 "/var/lib/mysql/mysql.sock", server_version =
0x502fe0 "5.0.20-standard",
host_info = 0x502f90 "à;P",
info = 0x0,
db = 0x510d10 "\0200P",
charset = 0x2a9580d840,
fields = 0x0,
field_alloc = {free = 0x0, used = 0x0, pre_alloc = 0x0, min_malloc = 32,
block_size = 8160, block_num = 4, first_block_usage = 0, error_handler =
0},
affected_rows = 18446744073709551615,
insert_id = 0,
extra_info = 0,
thread_id = 80,
packet_length = 7,
port = 0,
client_flag = 41613,
server_capabilities = 41516,
protocol_version = 10,
field_count = 0,
server_status = 2,
server_language = 8,
warning_count = 0,
options = {connect_timeout = 0, read_timeout = 0, write_timeout = 0,
port = 0, protocol = 0, client_flag = 0, host = 0x0, user = 0x0,
password = 0x0, unix_socket = 0x0, db = 0x0, init_commands = 0x0,
my_cnf_file = 0x0, my_cnf_group = 0x0, charset_dir = 0x0, charset_name =
0x0, ssl_key = 0x0, ssl_cert = 0x0, ssl_ca = 0x0, ssl_capath = 0x0,
ssl_cipher = 0x0, shared_memory_base_name = 0x0, max_allowed_packet = 0,
use_ssl = 0 '\0', compress = 0 '\0', named_pipe = 0 '\0', rpl_probe = 0
'\0', rpl_parse = 0 '\0', no_master_reads = 0 '\0', separate_thread = 0
'\0', methods_to_use = MYSQL_OPT_CONNECT_TIMEOUT, client_ip = 0x0,
secure_auth = 0 '\0', report_data_truncation = 0 '\0', local_infile_init
= 0, local_infile_read = 0, local_infile_end = 0, local_infile_error =
0, local_infile_userdata = 0x0},
status = MYSQL_STATUS_READY,
free_me = 0 '\0',
reconnect = 0 '\0',
scramble = "V_[*]uU,w5B-VJQ8eq*{",
rpl_pivot = 1 '\001',
master = 0x7fbffff370,
next_slave = 0x7fbffff370,
last_used_slave = 0x0,
last_used_con = 0x7fbffff370,
stmts = 0x0,
methods = 0x2a9590ce20,
thd = 0x0,
unbuffered_fetch_owner = 0x0},
is_connected_ = true,
connecting_ = false,
success_ = true,
pending_options_ =
{<std::_Deque_base<mysqlpp::Connection::OptionInfo,std::allocator<mysqlpp::Connection::OptionInfo>
>> = {_M_impl = {<std::allocator<mysqlpp::Connection::OptionInfo>> =
{<__gnu_cxx::new_allocator<mysqlpp::Connection::OptionInfo>> = {<No data
fields>}, <No data fields>}, _M_map = 0x5027b0, _M_map_size = 8,
_M_start = {_M_cur = 0x502800, _M_first = 0x502800, _M_last = 0x5029f8,
_M_node = 0x5027c8}, _M_finish = {_M_cur = 0x502800, _M_first =
0x502800, _M_last = 0x5029f8, _M_node = 0x5027c8}}}, <No data fields>},
static legal_opt_arg_types_ = {mysqlpp::Connection::opt_type_integer,
mysqlpp::Connection::opt_type_none, mysqlpp::Connection::opt_type_none,
mysqlpp::Connection::opt_type_string,
mysqlpp::Connection::opt_type_string,
mysqlpp::Connection::opt_type_string,
mysqlpp::Connection::opt_type_string,
mysqlpp::Connection::opt_type_string,
mysqlpp::Connection::opt_type_integer,
mysqlpp::Connection::opt_type_integer,
mysqlpp::Connection::opt_type_string,
mysqlpp::Connection::opt_type_integer,
mysqlpp::Connection::opt_type_integer,
mysqlpp::Connection::opt_type_none, mysqlpp::Connection::opt_type_none,
mysqlpp::Connection::opt_type_none, mysqlpp::Connection::opt_type_none,
mysqlpp::Connection::opt_type_string,
mysqlpp::Connection::opt_type_boolean,
mysqlpp::Connection::opt_type_boolean,
mysqlpp::Connection::opt_type_boolean,
mysqlpp::Connection::opt_type_boolean}}
-Matti
> mazah_82@stripped wrote:
> >
> > 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.
>
__
Saunalahti Xtra - Uusi GSM-vuokrapuhelin ja edistykselliset Xtra-palvelut
käyttöösi alk. 4,95 e/kk! http://saunalahti.fi/xtra/