List:MySQL++« Previous MessageNext Message »
From:Graham Reitz Date:December 4 2007 3:26am
Subject:Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0 (Part 2)
View as plain text  
Below is the rest of it...

5) The simple main function
6) gdb run with backtrace

5) Code:
#include <iostream>
#include <string>
#include <mysql++.h>

using namespace std;
using namespace mysqlpp;

int main (int argc, char * const argv[])
{
     string database_name = "tac_db_rev_4";
     string ip_address = "X.X.X.X";
     string username = "admin";
     string password = "admin";
     string client_id = "graham";
     string client_pw = "reitz";
     string error_msg;

     cout << "Attempting to connect to the database...";

     Connection m_connection(database_name.c_str(),
                             ip_address.c_str(),
                             username.c_str(),
                             password.c_str(),
                             3306,
                             false,
                             15);

     Result client_id_result;

	try
	{

         cout << "connected to the database\n";

         Query client_id_query = m_connection.query();

         client_id_query <<
         "select client_id from clients where client_user_name ="
         << quote_only << client_id << " and client_password ="
         << quote_only << client_pw;

         cout << "Query created: " << client_id_query.preview() << endl;

         client_id_result = client_id_query.store();

         if (client_id_result)
         {
             cout << "Result received = " << client_id_result.rows()
<< endl;
             Row client_id_row;
             Row::size_type i = 0;
             client_id_row = client_id_result.at(i);
         }

         Row client_id_row;
         // The "=" versus "==" syntax is more mysqlpp bs
         if (client_id_row = client_id_result.at(0))
         {
             cout << client_id_row.at(0) << endl;
             return client_id_row.at(0);
         }
     }
     catch (exception &e)
     {
         cout << "exception occurred...";
         cout << e.what() << endl;
     }
     catch (...)
     {
         error_msg = "Unknown exception";
         cout << error_msg << endl;
     }

     m_connection.close();

     return 0;
}

6) gdb run with backtrace

(gdb) run
Starting program: /Users/grahamreitz/Development/Projects/tac/build/
Debug/tac
Reading symbols for shared libraries ++++++... done
Attempting to connect to the database...connected to the database
Query created: select client_id from clients where client_user_name
='graham' and client_password ='reitz'
Result received = 1
/Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.0.0/bits/
stl_algobase.h:382:
     error: function requires a valid iterator range [__first, __last).

Objects involved in the operation:
iterator "__first" @ 0x0xbfffee50 {
type = N10__gnu_norm19_Bit_const_iteratorE;
}
iterator "__last" @ 0x0xbfffee58 {
type = N10__gnu_norm19_Bit_const_iteratorE;
}

Program received signal SIGABRT, Aborted.
0x9264e47a in __kill ()
(gdb) backtrace
#0  0x9264e47a in __kill ()
#1  0x9264e46d in kill$UNIX2003 ()
#2  0x926c5782 in raise ()
#3  0x926d4d3f in abort ()
#4  0x92b476f9 in __gnu_debug::_Error_formatter::_M_error ()
#5  0x00005bdb in std::copy<__gnu_norm::_Bit_const_iterator,
__gnu_norm::_Bit_iterator> (__first={<__gnu_norm::_Bit_iterator_base>
= {<> = {<No data fields>}, _M_p = 0x700bc4, _M_offset = 3221222728},
<No data fields>}, __last={<__gnu_norm::_Bit_iterator_base> = {<> =
{<No data fields>}, _M_p = 0xbffff601, _M_offset = 2413828210}, <No
data fields>}, __result={<__gnu_norm::_Bit_iterator_base> = {<> = {<No
data fields>}, _M_p = 0x1000000, _M_offset = 0}, <No data fields>}) at
stl_algobase.h:382
#6  0x00005cd6 in __gnu_norm::vector<bool, std::allocator<bool>
> ::operator= (this=0xbffff4c8, __x=@0xbffff5f0) at stl_bvector.h:709
#7  0x00005d3a in __gnu_debug_def::vector<bool, std::allocator<bool>
> ::operator= (this=0xbffff4c8, __x=@0xbffff5f0) at debug/vector:100
#8  0x00006eb4 in mysqlpp::Row::operator= (this=0xbffff4a0) at row.h:54
#9  0x00001ef9 in main (argc=1, argv=0xbffff6f0) at /Users/grahamreitz/
Development/Projects/tac/main.cpp:51
Thread
Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0 (Part 2)Graham Reitz4 Dec
  • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0 (Part 2) [SOLVED]Graham Reitz5 Dec
    • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0 (Part 2) [SOLVED]Graham Reitz5 Dec
    • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0(Part 2) [SOLVED]Warren Young5 Dec
      • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0 (Part 2) [SOLVED]Jonathan Wakely5 Dec
        • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0 (Part 2) [SOLVED]Graham Reitz5 Dec
          • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0 (Part 2) [SOLVED]Jonathan Wakely6 Dec
          • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0(Part 2) [SOLVED]Warren Young6 Dec
            • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0 (Part 2) [SOLVED]Graham Reitz6 Dec
              • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0Graham Reitz6 Dec
                • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0Graham Reitz7 Dec
                  • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0Graham Reitz7 Dec
                    • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0Graham Reitz7 Dec
              • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0 (Part 2) [SOLVED]Jonathan Wakely7 Dec
              • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0(Part 2) [SOLVED]Warren Young10 Jan
  • Re: Release works, Debug (still) crashes on OS X Leopard, Xcode 3.0 (Part 2)Jonathan Wakely5 Dec