| Bug #52773 | Segmentation fault occurs in mysqlslap with --auto-generate-sql-load-type=read | ||
|---|---|---|---|
| Submitted: | 13 Apr 2010 0:52 | Modified: | 6 Feb 2011 14:18 |
| Reporter: | Meiji KIMURA | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Command-line Clients | Severity: | S3 (Non-critical) |
| Version: | 1.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[13 Apr 2010 1:25]
Meiji KIMURA
[Workaround] Avoid these errors of mysql_store_result(), and re-run mysqlslap. #CR_OUT_OF_MEMORY:Out of memory. #CR_SERVER_GONE_ERROR:The MySQL server has gone away. #CR_SERVER_LOST:The connection to the server was lost during the query. #CR_UNKNOWN_ERROR:An unknown error occurred. For more details of these errors, see this manual. http://dev.mysql.com/doc/refman/5.1/en/mysql-store-result.html

Description: Under some environments, mysqlslap with --auto-generate-sql-load-type=read cause the segmenttation fault. I check the back trace of its core file, so I got the result below. (gdb) bt #0 mysql_fetch_row (res=0x0) at client.c:3019 #1 0x0000000000436efc in run_task (p=0x7fbfff9360) at mysqlslap.c:1900 #2 0x0000002a95672137 in ?? () #3 0x0000000000000000 in ?? () I checked the source codes(MySQL 5.1.42) around this, I found a bad codes befor mysql_fetch_row(). //->Start codes. do { if (mysql_field_count(mysql)) { result= mysql_store_result(mysql); while ((row = mysql_fetch_row(result))) counter++; mysql_free_result(result); } } while(mysql_next_result(mysql) == 0); //<-End codes. Immediate before mysql_fetch_row(), mysql_store_result() is called. The function sometimes returns null with error. So at that time, 'result' values become null and it cause the segmentation fault in mysql_fetch_row() function. More details about mysql_store_result's error, see this manual. http://dev.mysql.com/doc/refman/5.1/en/mysql-store-result.html How to repeat: See the errors of this manual and do it. http://dev.mysql.com/doc/refman/5.1/en/mysql-store-result.html Suggested fix: Check 'result' is null or not. If 'result' is null, print an error message and exit.