Re: when calling mysql_real_connect from the c api, I get a malloc() memory corruption error.

2008-10-29 Thread Micah Stevens
A working server relies on the MySQL binary, and system libraries, and 
the hardware itself. From your description you don't address the library 
compatibility. Have you ensured that your set of libraries is the same?


-Micah

On 10/29/2008 11:15 AM, Kevin Stevens wrote:

ello,
I am encountering a problem I just can't seem to figure out and I am out of 
ideas. I can compile and run fine on one linux box running Mysql 5.1.23-rc, but 
as soon as I scp the binary and its required libs to another machine which has 
identical hardware and only a slightly upgraded distro (but also running 
5.1.23-rc), I get a glibc malloc(): memory corruption: *** error, which traces 
back to the mysql_real_connect() call. I ran ldd -v on the binary on both 
machines and there are some differences, but they don't look important. I have 
run this binary on other machines before with no issues.

I can connect to the database on the troubled machine both locally from the 
client and through my program from a different machine, but my program craps 
out when I run it locally on this new box. What could be going wrong? The 
database connection is one of the first things the program does- before we do 
any significant allocation of memory, so I really do not believe that this is a 
problem with my program (it has also been continually tested with many 
different data sets).

I checked the bug database and this forum and could not find any relevant 
information, if you have any ideas, please let me know! Below is the output 
from my program, and the code I am using to connect- am I doing something wrong 
there? If there is any more information I can provide, please let me know.

Thank you,
-Kevin



Program output
==

Starting Engine...
Reading Control Data
Using configfile: /some.ini
Populating Data from Database...
DB Connection Handle is null, going to create a new connection!
We have created the handle... initializing.
We have initialized the handle, connecting...
Connecting with parameters: Server: localhost Login: root Pass: X 
DBDatabase: mismiats
*** glibc detected *** ./ksMismi2.out: malloc(): memory corruption: 
0x011d4b40 ***
=== Backtrace: =
/lib/libc.so.6[0x7f8f6919da14]
/lib/libc.so.6(__libc_malloc+0x90)[0x7f8f6919f360]
libmysqlclient.so.16(my_malloc+0x32)[0x7f8f6a6a5032]
libmysqlclient.so.16(vio_new+0x2f)[0x7f8f6a6cd15f]
libmysqlclient.so.16(mysql_real_connect+0xe43)[0x7f8f6a6c9fe3]
./ksMismi2.out[0x51671e]
./ksMismi2.out[0x51678b]
./ksMismi2.out[0xd5cd68]
./ksMismi2.out[0x57d32e]
./ksMismi2.out[0x57dc41]
./ksMismi2.out[0x49a251]
/lib/libc.so.6(__libc_start_main+0xf4)[0x7f8f691471c4]
./ksMismi2.out(__gxx_personality_v0+0x1c2)[0x4994ea]
=== Memory map: 
0040-01012000 r-xp  fe:00 2048027 /usr/local/engine/bin/ksMismi2.out
01112000-011a9000 rwxp 00c12000 fe:00 2048027 /usr/local/engine/bin/ksMismi2.out
011a9000-011f3000 rwxp 011a9000 00:00 0 [heap]
7f8f6000-7f8f60021000 rwxp 7f8f6000 00:00 0
7f8f60021000-7f8f6400 ---p 7f8f60021000 00:00 0
7f8f64c3-7f8f64c3a000 r-xp  fe:00 1171488 /lib/libnss_files-2.7.so
7

[ snipped... ]

7fff72b7d000-7fff72b92000 rwxp 7ffea000 00:00 0 [stack]
7fff72bfe000-7fff72c0 r-xp 7fff72bfe000 00:00 0 [vdso]
ff60-ff601000 r-xp  00:00 0 [vsyscall]




Code
==


MYSQL* dbConn::getDBConnectionHandle ()
{
my_bool reconn = 1;

if (DBconnectionHandle != NULL)
{
while ( !mysql_real_connect( DBconnectionHandle, DBServer.c_str(), 
DBLogin.c_str(), DBPassword.c_str(), DBDatabase.c_str(), DBPort, NULL, 
CLIENT_MULTI_STATEMENTS) ) //Client multi statements used for batched inserts 
of trades.
{
cout  ERROR: Connecting to MYSQL. ERROR Reported from Server is:   
mysql_error(DBconnectionHandle)  endl;
}

mysql_options( DBconnectionHandle, MYSQL_OPT_RECONNECT, (const char*)reconn ); 
// must do twice, bug in mysql lib

return DBconnectionHandle;
}
else
cout  DB Connection Handle is null, going to create a new connection!  
endl;

DBconnectionHandle = new MYSQL();
cout  We have created the handle... initializing.   endl;

if ( mysql_init(DBconnectionHandle) == NULL )
{
cout  ERROR: initializing connection handle: Error from Mysql:   
mysql_error(DBconnectionHandle)  endl;
return NULL;
}

cout  We have initialized the handle, connecting...  endl;
cout  Connecting with parameters: Server:   DBServer   Login:   DBLogin   Pass:   
DBPassword   DBDatabase:   DBDatabase  endl;


mysql_options( DBconnectionHandle, MYSQL_OPT_RECONNECT, (const char*)reconn );

while ( !mysql_real_connect( DBconnectionHandle, DBServer.c_str(), 
DBLogin.c_str(), DBPassword.c_str(), DBDatabase.c_str(), DBPort, NULL, 
CLIENT_MULTI_STATEMENTS) ) //Client multi statements used for batched inserts 
of trades.
{
cout  ERROR: Connecting to MYSQL. ERROR Reported from Server is:   
mysql_error(DBconnectionHandle)  endl;
}

mysql_options( DBconnectionHandle, MYSQL_OPT_RECONNECT, (const char*)reconn ); 
// must do twice, bug 

Re: when calling mysql_real_connect from the c api, I get a malloc() memory corruption error.

2008-10-29 Thread walter harms


Kevin Stevens schrieb:
 ello,
 I am encountering a problem I just can't seem to figure out and I am out of 
 ideas. I can compile and run fine on one linux box running Mysql 5.1.23-rc, 
 but as soon as I scp the binary and its required libs to another machine 
 which has identical hardware and only a slightly upgraded distro (but also 
 running 5.1.23-rc), I get a glibc malloc(): memory corruption: *** error, 
 which traces back to the mysql_real_connect() call. I ran ldd -v on the 
 binary on both machines and there are some differences, but they don't look 
 important. I have run this binary on other machines before with no issues.
 
 I can connect to the database on the troubled machine both locally from the 
 client and through my program from a different machine, but my program craps 
 out when I run it locally on this new box. What could be going wrong? The 
 database connection is one of the first things the program does- before we do 
 any significant allocation of memory, so I really do not believe that this is 
 a problem with my program (it has also been continually tested with many 
 different data sets).
 
 I checked the bug database and this forum and could not find any relevant 
 information, if you have any ideas, please let me know! Below is the output 
 from my program, and the code I am using to connect- am I doing something 
 wrong there? If there is any more information I can provide, please let me 
 know.
 
 Thank you,
 -Kevin
 
 
 

hi Kevin,
can you reproduce the bug when using a smaler version of you program ? a 
version that only open/close a connection ?

re,
 wh

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]