List:General Discussion« Previous MessageNext Message »
From:frankie Date:April 28 2004 9:01am
Subject:MySQLd crash within a UDF on Linux
View as plain text  
>Description:
	I'm experiencing a Linux-related only problem with a simple UDF which call 
	mysql_real_connect() 
>How-To-Repeat:

	A very simple function:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
                                                                                          
                                                                                          
                                                                   
#include "my_global.h"
#include "my_sys.h"
#include "mysql.h"
#include "m_ctype.h"
#include "m_string.h"
                                                                                          
                                                                                          
                                                                   
longlong myfunc(UDF_INIT *initid, UDF_ARGS *args, char *is_null,char *error )
{
        MYSQL mysql;
 
        mysql_init(&mysql);
 
        if (!(mysql_real_connect(&mysql,"localhost","root","","test", 0 , NULL , 0 )))
{
                *error=1;
                return (longlong)(-1);
        }
 
        mysql_close(&mysql);
        return (longlong)1;
}


compiled with

gcc -I /usr/include/mysql -shared -o libmyfunc.so myfunc.c -lmysqlclient_r

The thread crashes with:

thd=0x847bc78
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=0x43be4d0c, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x810cdbc
0xffffe420
0x1
0x43bf47c1
0x80d0042
0x80d0082
0x80c5061
0x8100ce7
0x813c64b
0x813b5d0
0x811b08b
0x811f60e
0x811a066
0x8119a57
0x8119025
0x401b39b4
0x847c89c
New value of fp=0x43be6bb0 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 0x84761b0 = select myfunc("prova")
thd->thread_id=1


I'm available to provide more details, anyway it seems crashing within a syscall.
If I run the program with --one-thread it does not crash but returns NULL.
I could provide more details on request.

	
>Fix:
	None known.

>Submitter-Id:	frankie
>Originator:	Francesco Paolo Lovergine
>Organization:  Debian
>
>MySQL support: none 
>Synopsis:	udf problem on linux
>Severity:	serious
>Priority:	medium 
>Category:	mysql
>Class:		sw-bug
>Release:	mysql-4.0.18 (Source distribution)

>C compiler:    gcc (GCC) 3.3.3 (Debian 20040401)
>C++ compiler:  g++ (GCC) 3.3.3 (Debian 20040401)
>Environment:   Debian GNU/Linux, arch i386, libc and gcc below.
System: Linux klecker 2.6.5-1-686 #1 Sat Apr 24 08:47:10 EST 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
Configured with: ../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 (Debian 20040401)
Compilation info: CC='gcc'  CFLAGS=''  CXX='g++'  CXXFLAGS=''  LDFLAGS=''  ASFLAGS=''
LIBC: 
lrwxrwxrwx    1 root     root           13 2004-04-24 22:22 /lib/libc.so.6 ->
libc-2.3.2.so
-rw-r--r--    1 root     root      1243792 2004-04-21 20:58 /lib/libc-2.3.2.so
-rw-r--r--    1 root     root      2640378 2004-04-21 20:59 /usr/lib/libc.a
-rw-r--r--    1 root     root          204 2004-04-21 20:34 /usr/lib/libc.so
lrwxrwxrwx    1 root     root           28 2004-03-24 10:01
/usr/lib/libc-client.so.2002edebian -> libc-client.so.2002edebian.1
-rw-r--r--    1 root     root       767184 2004-03-22 23:31
/usr/lib/libc-client.so.2002edebian.1
Configure command: ./configure '--prefix=/usr' '--exec-prefix=/usr'
'--libexecdir=/usr/sbin' '--datadir=/usr/share' '--sysconfdir=/etc/mysql'
'--localstatedir=/var/lib/mysql' '--includedir=/usr/include' '--infodir=/usr/share/info'
'--mandir=/usr/share/man' '--enable-shared' '--enable-static'
'--enable-thread-safe-client' '--enable-assembler' '--enable-local-infile' '--with-raid'
'--with-unix-socket-path=/var/run/mysqld/mysqld.sock' '--with-mysqld-user=mysql'
'--with-libwrap' '--with-client-ldflags=-lstdc++' '--with-embedded-server' '--with-vio'
'--with-openssl' '--without-docs' '--without-bench' '--without-readline'
'--with-extra-charsets=all' '--with-berkeley-db' '--with-innodb' '--with-debug'

Thread
MySQLd crash within a UDF on Linuxfrankie28 Apr