Bug #38570 calling UDF causes a server crash

Submitted: 5 Aug 2008 12:13 Modified: 8 Aug 2008 6:18
Reporter: Susanne Ebrecht Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S3 (Non-critical)
Version:5.0, 5.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: regression

[5 Aug 2008 12:13] Susanne Ebrecht
Description:
I worked on bug #38257

SELECT udf_real_max_length();
080805 13:22:20 - mysqld got signal 10 ;
....
ERROR 2013 (HY000): Lost connection to MySQL server during query

How to repeat:
FIle: udf_return_values.c
-------------------------
#include <string.h>

#include <my_global.h>
#include <mysql.h>

#if defined(_WIN32) || defined(_WIN64)
#define DLLEXP __declspec(dllexport)
#else
#define DLLEXP /* no dll */
#endif

#ifdef __cplusplus
extern "C" {
#endif
DLLEXP my_bool udf_int_max_length_init(UDF_INIT *initid){
  return 0;
}

DLLEXP longlong udf_int_max_length(
  UDF_INIT *initid, UDF_ARGS *args,
  my_bool *is_null, my_bool *error
){
  return initid->max_length;
}

DLLEXP my_bool udf_real_max_length_init(UDF_INIT *initid){
  initid->decimals = 0;
  return 0;
}

DLLEXP double udf_real_max_length(
  UDF_INIT *initid, UDF_ARGS *args,
  my_bool *is_null, my_bool *error
){
  initid->decimals = 0;
  return (double)initid->max_length;
}

DLLEXP my_bool udf_str_max_length_init(UDF_INIT *initid){
  initid->decimals = 0;
  return 0;
}

DLLEXP char* udf_str_max_length(
  UDF_INIT *initid, UDF_ARGS *args,
  char* buffer, unsigned long* length,
  my_bool *is_null, my_bool *error
){
  initid->decimals = 0; 
  sprintf(buffer, "%u\0", initid->max_length);
  *length = strlen(buffer);
  return buffer;
}
#ifdef __cplusplus
}
#endif

Compile:
--------
gcc -Wall -I/opt/mysql/mysql/include -shared -o udf_return_values.so udf_return_values.c

Move udf_return_values.so to plugin dir
---------------------------------------

CREATE FUNCTION udf_real_max_length RETURNS REAL soname 'udf_return_values.so';
Query OK, 0 rows affected (0.00 sec)

SELECT udf_real_max_length();
[7 Aug 2008 21:04] MySQL Verification Team
Omer,

Regression was noticed with 5.0.22 see bug and my comment below:

http://bugs.mysql.com/bug.php?id=38257

[21 Jul 20:03] Miguel Solorzano

Thanks.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.