>Description:
Maybe that I abuse the API. Nevertheless, the server should
not crash. I tried with a self-compiled kernel, from the 5.0
bitkeeper repository and with the pre-compiled version
mysql-standard-5.0.0-alpha-pc-linux-i686.
The message is:
mysqld got signal 11;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.
key_buffer_size=8388600
read_buffer_size=131072
max_used_connections=0
max_connections=100
threads_connected=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 225791 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
thd=0x863fc18
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0xbfe7f598, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x80880d3
0x82df1d8
0x82dd68b
0x8307dda
0x82bc8b6
0x82bce99
0x808179d
0x807eaf9
0x8087cf8
0x8093c22
0x82dc98c
0x83124ca
New value of fp=(nil) failed sanity check, terminating stack trace!
Please read http://www.mysql.com/doc/en/Using_stack_trace.html and follow instructions
on how to resolve the stack trace. Resolved
stack trace is much more helpful in diagnosing the problem, so please do
resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at (nil) is invalid pointer
thd->thread_id=1
The manual page at http://www.mysql.com/doc/en/Crashing.html contains
information that should help you find out what is causing the crash.
My own kernel does not produce a useful backtrace, but
the standard kernel does:
0x80880d3 handle_segfault + 423
0x82df1d8 pthread_sighandler + 184
0x82dd68b pthread_mutex_lock + 11
0x8307dda free + 122
0x82bc8b6 my_no_flags_free + 22
0x82bce99 free_root + 149
0x808179d _._9Statement + 37
0x807eaf9 _._3THD + 517
0x8087cf8 end_thread__FP3THDb + 64
0x8093c22 handle_one_connection + 914
0x82dc98c pthread_start_thread + 220
0x83124ca thread_start + 4
>How-To-Repeat:
Here is the test program. Call it as "bug_prepared -q" for using
mysql_query only (wich succeeds) or "bug_prepared -p" for using
mysql_prepare/mysql_execute. The program needs a database
"test_7". It creates a table "tab2", inserts a row, selects it
back, sleeps 5 seconds to prove that the crash comes during
closing the session, closes and exits.
/* bug_prepared.c
*
* Copyright 2004 Ingo Struewing
*
* Show a server bug during close after executing prepared SQL.
*/
static char *USAGE[] =
{
"Usage: bug_prepared -p|-q \n",
0};
#define ARGS(x) ( ((x) == 1) )
#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
#include <mysql.h>
#include <mysqld_error.h>
char *program ;
MYSQL mysql_structure ;
MYSQL *mysql = &mysql_structure ;
void
check_error ( char *message ,
unsigned int acceptable_1 ,
unsigned int acceptable_2 ,
unsigned int acceptable_3 );
/*==========================================================================*/
int
main ( int argc ,
char **argv )
{
int argn ;
int use_prepared ;
char *host ;
char *user ;
char *passwd ;
char *db ;
unsigned int port ;
char *unix_socket ;
unsigned long client_flag ;
char *query ;
MYSQL_STMT *stmt ;
MYSQL_BIND bind[4] ;
long int producer ;
unsigned long amount_length ;
unsigned long size_length ;
unsigned long fruit_length ;
MYSQL_RES *result_set ;
MYSQL_ROW row ;
/*
* Get options.
*/
argn = 1 ;
if ( ! ARGS(argc - argn) )
{
for ( argn = 0 ; USAGE[argn] ; argn ++ )
(void) fprintf ( stderr , "%s" , USAGE[argn] );
return ( 1 );
}
if ( ! strcmp ( argv[argn] , "-p" ) )
{
use_prepared = 1 ;
}
else if ( ! strcmp ( argv[argn] , "-q" ) )
{
use_prepared = 0 ;
}
else
{
for ( argn = 0 ; USAGE[argn] ; argn ++ )
(void) fprintf ( stderr , "%s" , USAGE[argn] );
return ( 1 );
}
/*
* Get program name.
*/
program = strrchr ( argv[0] , '/' );
if ( program )
program ++ ;
else
program = argv[0];
/*
* Set connection values.
*/
host = NULL ;
user = NULL ;
passwd = NULL ;
db = "test_7" ;
port = 0 ;
unix_socket = NULL ;
client_flag = 0 ;
/*
* Initialize the mysql structure.
*/
if ( ! mysql_init ( mysql ) )
{
fprintf ( stderr , "cannot create mysql structure \n" );
return ( 3 );
}
/*
* Get default options.
*/
mysql_options ( mysql , MYSQL_READ_DEFAULT_GROUP , program );
check_error ( "mysql_options" , 0 , 0 , 0 );
/*
* Connect to the server.
*/
mysql_real_connect ( mysql , host , user , passwd , db , port ,
unix_socket , client_flag );
check_error ( "mysql_real_connect" , 0 , 0 , 0 );
printf ( "connected \n" );
/*
* Drop a table which may exist from former tries.
*/
mysql_query ( mysql , "drop table bug_prepared" );
check_error ( "mysql_query drop database" , ER_BAD_TABLE_ERROR , 0 , 0 );
printf ( "dropped table \n" );
/*
* Create a new table.
*/
mysql_query ( mysql , "create table bug_prepared ( "
"producer fixed(10), "
"amount char(10), "
"size char(10), "
"fruit char(20) )" );
check_error ( "mysql_query create table" , 0 , 0 , 0 );
printf ( "created table \n" );
if ( use_prepared )
{
/*
* Prepare SQL statement.
*/
query = "insert bug_prepared values (?,?,?,?)" ;
stmt = mysql_prepare ( mysql , query , strlen(query) );
check_error ( "mysql_prepare insert" , 0 , 0 , 0 );
/*
* Validate parameter count.
*/
if ( mysql_param_count ( stmt ) != 4 )
{
fprintf ( stderr , "invalid parameter count returned by MySQL \n" );
exit ( 4 );
}
/*
* Setup parameter bindings.
* The first is a number type,
* so there is no need to specify buffer_length
*/
bind[0].buffer_type = MYSQL_TYPE_LONG;
bind[0].is_null = FALSE ;
bind[0].buffer = (void*) &producer ;
producer = 1 ;
bind[0].length = 0 ;
bind[1].buffer_type = MYSQL_TYPE_STRING;
bind[1].is_null = FALSE ;
bind[1].buffer = "five" ;
amount_length = 4 ;
bind[1].buffer_length = amount_length ;
bind[1].length = &amount_length ;
bind[2].buffer_type = MYSQL_TYPE_STRING;
bind[2].is_null = FALSE ;
bind[2].buffer = "big" ;
size_length = 3 ;
bind[2].buffer_length = size_length ;
bind[2].length = &size_length ;
bind[3].buffer_type = MYSQL_TYPE_STRING;
bind[3].is_null = FALSE ;
bind[3].buffer = "apple" ;
fruit_length = 5 ;
bind[3].buffer_length = fruit_length ;
bind[3].length = &fruit_length ;
mysql_bind_param ( stmt , bind );
check_error ( "mysql_bind_param" , 0 , 0 , 0 );
printf("%lu %lu '%s' %lu %lu '%s' %lu %lu '%s' \n",
*bind[1].length, bind[1].buffer_length, bind[1].buffer,
*bind[2].length, bind[2].buffer_length, bind[2].buffer,
*bind[3].length, bind[3].buffer_length, bind[3].buffer );
/*
* Execute the prepared statement
*/
mysql_execute ( stmt );
check_error ( "mysql_execute insert" , 0 , 0 , 0 );
/*
* Free the statement resources
*/
mysql_stmt_close ( stmt );
check_error ( "mysql_stmt_close" , 0 , 0 , 0 );
}
else
{
mysql_query ( mysql ,
"insert bug_prepared values (1,'five','big','apple')" );
check_error ( "mysql_query insert" , 0 , 0 , 0 );
}
/*
* Select back what we have inserted.
*/
mysql_query ( mysql , "select * from bug_prepared" );
check_error ( "mysql_query select" , 0 , 0 , 0 );
/*
* Fetch the whole result set.
*/
result_set = mysql_store_result ( mysql );
check_error ( "mysql_query fetch result set" , 0 , 0 , 0 );
/*
* Fetch and print each row.
*/
for (;;)
{
row = mysql_fetch_row ( result_set );
check_error ( "mysql_query fetch row" , 0 , 0 , 0 );
if ( ! row )
{
printf ( "no more rows \n" );
break ;
}
printf ( "selected %10s %10s %10s %10s \n",
row[0] ? row[0] : "(NULL)" ,
row[1] ? row[1] : "(NULL)" ,
row[2] ? row[2] : "(NULL)" ,
row[3] ? row[3] : "(NULL)" );
}
/*
* Free the result set.
*/
mysql_free_result ( result_set );
/*
* Wait a moment to prove that the server crashes at close.
*/
printf ( "sleeping before closing... \n" );
sleep ( 5 ); /* see when the server crashes */
printf ( "awoke from sleep. closing now... \n" );
/*
* Close connection.
*/
mysql_close ( mysql );
printf ( "closed \n" );
/*
* Terminate program.
*/
return ( 0 );
}
/*==========================================================================*/
void
check_error ( char *message ,
unsigned int acceptable_1 ,
unsigned int acceptable_2 ,
unsigned int acceptable_3 )
{
unsigned int errnum ;
errnum = mysql_errno ( mysql );
if ( (errnum == 0)
|| (errnum == acceptable_1)
|| (errnum == acceptable_2)
|| (errnum == acceptable_3)
)
{
return ;
}
fprintf ( stderr , "%s: %s: %d, %s \n",
program , message , errnum , mysql_error(mysql) );
mysql_close ( mysql );
exit ( 2 );
}
>Fix:
Besides getting the server crash fixed, I would like to hear,
how to change my program to avoid the crash.
>Submitter-Id: <submitter ID>
>Originator: MySQL Development
>Organization: private
>MySQL support: none
>Synopsis: mysqld crashes when closing a prepare/execute session
>Severity: serious
>Priority: medium
>Category: mysql
>Class: sw-bug
>Release: mysql-5.0.0-alpha (Source distribution)
>C compiler: gcc (GCC) 3.3.3 20031206 (prerelease) (Debian)
>C++ compiler: gcc (GCC) 3.3.3 20031206 (prerelease) (Debian)
>Environment: PC, Debian GNU/Linux (sid), Pentium 4
libc6 2.3.2.ds1-10
zlib1g 1.2.1-3
System: Linux chilla 2.6.0-test11 #1 Sun Jan 4 17:04:51 CET 2004 i686 GNU/Linux
Architecture: i686
Some paths: /usr/bin/perl /usr/bin/make /usr/bin/gcc /usr/bin/cc
GCC: Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/specs
Konfiguriert mit: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu
--enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc
i486-linux
Thread model: posix
gcc-Version 3.3.3 20031229 (prerelease) (Debian)
Compilation info: CC='gcc' CFLAGS='-g -march=pentium4' CXX='gcc' CXXFLAGS='-g
-march=pentium4 -felide-constructors -fno-exceptions -fno-rtti' LDFLAGS='' ASFLAGS=''
LIBC:
lrwxrwxrwx 1 root root 13 2003-11-15 12:44 /lib/libc.so.6 ->
libc-2.3.2.so
-rw-r--r-- 1 root root 1243076 2003-11-05 20:17 /lib/libc-2.3.2.so
-rw-r--r-- 1 root root 2537670 2003-11-05 20:18 /usr/lib/libc.a
-rw-r--r-- 1 root root 204 2003-11-05 20:07 /usr/lib/libc.so
Configure command: ./configure '--prefix=/usr/local/mysql'
'--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock' '--with-debug' 'CFLAGS=-g
-march=pentium4' 'CXXFLAGS=-g -march=pentium4 -felide-constructors -fno-exceptions
-fno-rtti' 'CXX=gcc'
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]