Bug #10319 MySQL server crashes with SIGSEGV (4.1, 5.0)
Submitted: 2 May 2005 19:32 Modified: 2 Aug 2005 9:06
Reporter: Andrey Hristov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.12, 5.0.6-dev OS:Linux (Linux SuSE 9.1 (upgr to 9.2). Kernel 2.6.8)
Assigned to: Andrey Hristov CPU Architecture:Any

[2 May 2005 19:32] Andrey Hristov
Description:
The following C program leads to core dump in the server.
Compiled with :
andrey@whirlpool:~/tst> gcc -g -o simple simple.c -I/home/andrey/mysql-4.1/include/ -L/home/andrey/mysql-4.1/libmysql/.libs -lmysqlclient -lz -static

How to repeat:
#include <stdio.h>
#include "mysql.h"

int main(void)
{
	MYSQL *conn,*rconn;
	MYSQL_RES *res;
	MYSQL_ROW row;
	int i=0,j=0,k;
	
	conn = mysql_init(NULL);
	rconn = mysql_real_connect(conn, "127.0.0.1", "root", "", "test", 0, NULL, 0);	
	if (!rconn) {fprintf(stderr, "got NULL\n");exit(1);}
	rconn->reconnect = 0;
	i = mysql_query(rconn, "SELECT * FROM t123;");
	res = mysql_store_result(rconn);
	printf("number of rows : %d\n", mysql_num_rows(res));
	j = mysql_num_rows(res);
	i = mysql_num_fields(res);
	while (j-- > 0) {
		row = mysql_fetch_row(res);
		for (k = 0; k < i; ++k) {
			printf("%s\t", row[k]);
		}
		printf("\n");
	}
	mysql_free_result(res);
[2 May 2005 19:36] Andrey Hristov
And the backtrace (5.0.6):
0x80e5a09 handle_segfault + 417
0x836657d __pthread_sighandler + 173
0x400832f2 __stop___libc_freeres_ptrs + 933631214
0x40071aff __stop___libc_freeres_ptrs + 933559547
0x40071bbd __stop___libc_freeres_ptrs + 933559737
0x40019075 __stop___libc_freeres_ptrs + 933196401
0x40019504 __stop___libc_freeres_ptrs + 933197568
0x83963a2 __new_gethostbyaddr_r + 226
0x839621f gethostbyaddr + 143
0x80ec14e ip_to_hostname(in_addr*, unsigned int*) + 424
0x80f9b9b check_connection(THD*) + 311
0x80fa3fc handle_one_connection + 312
0x83615be pthread_start_thread + 222
0x839424a __clone + 106
[2 May 2005 20:54] MySQL Verification Team
I wasn't able to repeat with 5.0 BK source on Windows and Linux:

C:\temp>bug10319
number of rows : 2
1
2

miguel@hegel:~/dbs/5.0$ ./simple
number of rows : 2
1
2
[2 Aug 2005 9:06] Andrey Hristov
can't reproduce any more