List:Connector/C++« Previous MessageNext Message »
From:Mischief Maker Date:March 22 2009 11:25pm
Subject:MySQL Connector/C++ 1.0.3alpha crash in sql::mysql::MySQL_Connection::init()
View as plain text  
hello MySQL Connector/C++ mailing list! this is my first time using a
mailing list so forgive me if i have done this incorrectly.

i am encountering an error using MySQL Connector/C++ 1.0.3alpha and Visual
Studio 9 2008. my current code is as follows, just a simple connection test.

#include <string>
#include <iostream>
#include <driver/mysql_public_iface.h>


int main()
{
    std::string host("tcp://localhost:3306");
    const std::string user("foo");
    const std::string pass("bar");
    try {

        sql::Driver *driver = get_driver_instance();
        std::auto_ptr< sql::Connection > con( driver->connect(host, user,
pass) );
    }
    catch( sql::SQLException &e )
    {
        std::cout << "Something bad happened: " << e.what() << " - MySQL
ErrNo. " << e.getErrorCode() << std::endl;
    }
}

however, whenever i append the port on to the 'host' string, the call to the
sql::Connection ctor causes my program to crash.
the error is this:

Unhandled exception at 0x7855b690 (msvcr90.dll) in MySQLtest.exe:
0xC0000005: Access violation reading location 0xcccccccc.

and the call stack is this:

>    msvcr90.dll!strlen(buf=0x003c3be8)  Line 81    Asm

msvcp90.dll!std::basic_string<char,std::char_traits<char>,std::allocator<char>
>::assign(_Ptr=0xcccccccc)  Line 1095    C++

mysqlcppconn.dll!sql::mysql::MySQL_Connection::init(properties=[3](("hostName",{str={...}
dval=-9.2559631349317831e+061 lval=-3689348814741910324
...}),("password",{str={...} dval=-9.2559592131646239e+061
lval=-3689348818176639260 ...}),("userName",{str={...}
dval=-9.2559592131646696e+061 lval=-3689348818176639220 ...})))  Line 189
C++

mysqlcppconn.dll!sql::mysql::MySQL_Connection::MySQL_Connection(hostName=<Bad
Ptr>, userName="è:<", password="ÌÌÌÌbar")  Line
> 100    C++
     mysqlcppconn.dll!sql::mysql::MySQL_Driver::connect(hostName=<Bad Ptr>,
userName="ÌÌÌÌfoo",
password="ÌÌÌÌbar")  Line 69    C++
     MySQLtest.exe!main()  Line 15    C++
     MySQLtest.exe!__tmainCRTStartup()  Line 586    C
     MySQLtest.exe!mainCRTStartup()  Line 403    C
     kernel32.dll!_BaseProcessStart@4()

it seems to be occuring on this assignment, line 82 of
mysql-connector-c++-1.0.3-alpha\driver\mysql_connection.cpp

connection_properties[std::string("hostName")] = tmp;

but this is all i could find out really. i don't really know what else to
do, so i came to the mailing list. :)

also, another thing that struck me as odd. why are there those odd
characters appearing in the strings, i.e. userName="ÌÌÌÌfoo" ?

Thread
MySQL Connector/C++ 1.0.3alpha crash in sql::mysql::MySQL_Connection::init()Mischief Maker23 Mar