Bug #24847 MySQL Server crashes on query with custom functions
Submitted: 6 Dec 2006 10:02 Modified: 12 Dec 2006 9:35
Reporter: Tobias Schlatter Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: User-defined functions ( UDF ) Severity:S3 (Non-critical)
Version:5.0.30-Debian_0.dotdeb.1 OS:Linux (Debian Linux 2.4.27-2-386)
Assigned to: Sveta Smirnova CPU Architecture:Any

[6 Dec 2006 10:02] Tobias Schlatter
Manufacturer of machine is unknown; I will get it if necessary, but it would take it's time.

Following query lets the server crash, mysql client outputs:
ERROR 2013 (HY000): Lost connection to MySQL server during query

SELECT *, STEUERN_CH_E(steuern_kanton.kantonID,0,0,0) AS kant_e, STEUERN_CH_E(steuern_kanton.kantonID,0,0,0,1) AS gem_e, STEUERN_CH_V(steuern_kanton.kantonID,0,0,0) AS kant_v, STEUERN_CH_V(steuern_kanton.kantonID,0,0,0,1) AS gem_v FROM steuern_kanton CROSS JOIN bezirk USING (kantonID) CROSS JOIN gemeinde USING (bezirkID) CROSS JOIN plz4 USING (gemeindeID) CROSS JOIN steuern USING (gemeindeID) WHERE 1 AND ( plz4.plzname LIKE '%as%' OR plz4.plzname LIKE '%as% ') GROUP BY gemeinde.gemeindeID

It doesn't matter, if I use 'as' (in the like statement), or another short character sequence (as long as it is short). If the char seq. is longer, the query returns without problems an correct results.

The bug also doesn't occur, if I remove the STEUERN_CH_ function evaluations.

I've already found some tiny stuff about this bug, but the only solution was to increase max_allowed_packet which didn't help me.

sql_mode is unknown (mysqladmin variables dispalays an empty value there)

Attached (if possible, or as ftp upload) you will find the output (stdout and stderr) of mysqld, the resolved stack trace, table structure (with some exceptions), mysql configuration and a partial source for the functions.

How to repeat:
execute the query above (if you need the functions, I can also post the shared library, if you whish)
[6 Dec 2006 10:03] Tobias Schlatter
Mysql configuration

Attachment: my.cnf (application/octet-stream, text), 3.59 KiB.

[6 Dec 2006 10:08] Tobias Schlatter
Output of mysqld_safe

Attachment: my.log (application/octet-stream, text), 791 bytes.

[6 Dec 2006 10:16] Tobias Schlatter
Output of mysqld (stdout and stderr)

Attachment: mysql.log (application/octet-stream, text), 2.57 KiB.

[6 Dec 2006 10:16] Tobias Schlatter
Resolved stack trace

Attachment: mysql.res (application/octet-stream, text), 1.45 KiB.

[6 Dec 2006 10:17] Tobias Schlatter
explain of query

Attachment: explain (application/octet-stream, text), 468 bytes.

[6 Dec 2006 10:22] Tobias Schlatter
Table structure dump

Attachment: t_dump (application/octet-stream, text), 1.18 KiB.

[6 Dec 2006 11:14] Sveta Smirnova
Thank you for the report.

Please provide output of SHOW CREATE POCEDURE STEUERN_CH_ for each of your STEUERN_CH_ procedure
[7 Dec 2006 7:25] Tobias Schlatter
STEUERN_CH_ isn't a procedure, but a custom function. I will attach the header and some part of the source files which i used to compile the shared object library. (I'm afraid I can't give you all of the source files, but I will provide you with the compiled .so, if needed)
[7 Dec 2006 7:26] Tobias Schlatter
Source file for mysql

Attachment: steuern_ch.c (application/octet-stream, text), 8.47 KiB.

[7 Dec 2006 7:26] Tobias Schlatter
Header file

Attachment: steuern_ch.h (application/octet-stream, text), 4.56 KiB.

[12 Dec 2006 9:35] Tobias Schlatter
I just found the reason for the "bug"...
It was a Segmentation Fault in a part of my module, which is only called about a one 25th of the module calls, so I didn't find out...

sorry for the inconvenience