Bug #35460 UDF Crash
Submitted: 20 Mar 2008 14:30 Modified: 20 Mar 2008 17:14
Reporter: Sedat Onur ORAKOGLU Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.45-community-nt OS:Windows (ALL)
Assigned to: CPU Architecture:Any
Tags: UDF crash

[20 Mar 2008 14:30] Sedat Onur ORAKOGLU
Description:
i have an udf that gets me serial number of the first harddisk.
and it is working when i call it from Query Browser.
but, when i call the function from mysql.exe client program ;
sometimes the function returns like this:

########################################################

mysql> DROP FUNCTION XDT_GETMAC;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE FUNCTION XDT_GETMAC RETURNS STRING SONAME "GETMAC.DLL";
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT XDT_GETMAC();
+-------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-------------------------------------------------+
| XDT_GETMAC()

                                                 |
+-------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-------------------------------------------------+
| EC1D-65C5       ¦   v   ¦   ^K¦
  ÀO    öOÀO--â¦--â¦& >    Óİä     O   ¢‹^ H¦F¦>   '        H F¦Ç¹U¦POF¦ê-ü¦0¦F¦
xL>w£k5w¦   A¬5w¦¦5w>   >       *çW Çaù ÿêG ³Lå¦ÓL妨­+
m >   T¾+ i¦    ^   -´·­·
Lás Lás     T¾+ ^­·
    Ï;ä Lás ê-ü¦Ç+V -»b  ›c Ï;ä Lás     xÖä P¿L õçå¦Ï?+
¦   `Lå¦@¾+
ñ½L ¦  O +L ²,  M    v+L ×´+
Ó-妭-å¦++L     Ï?+
êqâ l¿v ×´+
@¾+
T¾+
P   P        Cä O´+ h-å¦Lás ¶   ?   ü       ²   -­·
Ïå¦    Ï +
DÎå¦    $Îå¦DÎ妭-妵GU XÍå¦    8 +
­-å¦O   4tT º¦¦
XÍå¦    ¶-U ²,  MÙ>Q Ï +
¦   Ï  |
+-------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-------------------------------------------------+
1 row in set (0.00 sec)

mysql>

########################################################

but many times server crashes and stop working..

########################################

mysql> DROP FUNCTION XDT_GETMAC;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT XDT_GETMAC();
ERROR 1305 (42000): FUNCTION mysql.XDT_GETMAC does not exist
mysql> CREATE FUNCTION XDT_GETMAC RETURNS STRING SONAME "GETMAC.DLL";
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT XDT_GETMAC();
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>

########################################

How to repeat:
allways
[20 Mar 2008 14:32] Sedat Onur ORAKOGLU
the udf that i load

Attachment: getmac.dll (application/x-msdownload, text), 60.00 KiB.

[20 Mar 2008 14:44] MySQL Verification Team
Thank you for the bug report. Could you please try with latest released version
if the crash still exists, please provide the C code to build the dll on our
side. Thanks in advance.
[20 Mar 2008 15:03] Sedat Onur ORAKOGLU
yes i tried it on 5.0.51a-community-nt and the error still remains.
the udf was running until last 2-3 days. i changed the .ini file. than this begins.
i'm sending the old ini file, the new ini file and the source of the dll.

thanks.
[20 Mar 2008 15:04] Sedat Onur ORAKOGLU
the old ini file

Attachment: old.ini (application/octet-stream, text), 502 bytes.

[20 Mar 2008 15:05] Sedat Onur ORAKOGLU
the new ini file

Attachment: new.ini (application/octet-stream, text), 573 bytes.

[20 Mar 2008 17:14] Sedat Onur ORAKOGLU
i solved the problem.

i replaced XDT_GETMAC_init function
with this

my_bool XDT_GETMAC_init(UDF_INIT *initid, UDF_ARGS *args, char *msg)
{

	my_bool status;
	if(args->arg_count!=0){
		strcpy(msg,"No arguments allowed");
		status = 1;
	} else {
		status = 0;
		//args->arg_type[0] = STRING_RESULT;
		//initid->maybe_null = 0;
		initid->max_length = 10;
	}
	return status;
}

that solves.

thanks..