List:Commits« Previous MessageNext Message »
From:uwendel Date:August 10 2007 1:10pm
Subject:PHP mysqlnd svn commit: r874 - trunk/tests/ext/mysqli
View as plain text  
Author: uwendel
Date: 2007-08-10 15:10:11 +0200 (Fri, 10 Aug 2007)
New Revision: 874

Modified:
   trunk/tests/ext/mysqli/mysqli_pconn_kill.phpt
Log:
A segfault, a segfault - yippie

==10893== Invalid read of size 4
==10893==    at 0x823DCD8: mysqlnd_stream_write_w_header (mysqlnd_wireprotocol.c:296)
==10893==    by 0x823DF24: php_mysqlnd_cmd_write (mysqlnd_wireprotocol.c:891)
==10893==    by 0x823AAC7: mysqlnd_simple_command (mysqlnd.c:367)
==10893==    by 0x823AEAA: mysqlnd_send_close (mysqlnd.c:987)
==10893==    by 0x823AF2C: php_mysqlnd_conn_close_pub (mysqlnd.c:1044)
==10893==    by 0x80FD90E: php_mysqli_dtor (mysqli.c:81)
==10893==    by 0x8293711: plist_entry_destructor (zend_list.c:210)
==10893==    by 0x8290C37: zend_hash_apply_deleter (zend_hash.c:611)
==10893==    by 0x8290E77: zend_hash_graceful_reverse_destroy (zend_hash.c:646)





Modified: trunk/tests/ext/mysqli/mysqli_pconn_kill.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_pconn_kill.phpt	2007-08-10 10:21:18 UTC (rev 873)
+++ trunk/tests/ext/mysqli/mysqli_pconn_kill.phpt	2007-08-10 13:10:11 UTC (rev 874)
@@ -18,21 +18,61 @@
 	if (!$plink = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
 		printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***,
dbname=%s, port=%s, socket=%s\n",
 			$host, $user, $db, $port, $socket);
-			
+	
+	// get the thread ids of the two connections...
+	$thread_id = mysqli_thread_id($link);
+	$pthread_id = mysqli_thread_id($plink);
+	
+	if (!$res = mysqli_query($link, 'SHOW FULL PROCESSLIST'))
+		printf("[002] Cannot get processlist, [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+	
+	$running_threads = array();
+	while ($row = mysqli_fetch_assoc($res))
+		$running_threads[$row['Id']] = $row;
+	mysqli_free_result($res);
+	var_dump($running_threads);
+	
+	if (count($running_threads) < 2)
+		printf("[003] Processlist is too short, [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+	if (!isset($running_threads[$thread_id]))
+		printf("[004] Cannot find thread id of the regular link, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
+	
+	if (!isset($running_threads[$pthread_id]))
+		printf("[005] Cannot find thread id of the persistent link, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
+
 	// Kill the persistent connection - don't use mysqli_kill, mysqlnd will catch that...
-	$pthread_id = mysqli_thread_id($plink);
 	if (!mysqli_query($link, sprintf('KILL %d', $pthread_id)))
-		printf("[002] Cannot kill persistent connection, [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
-
-	if ($res = @mysql_query($plink, 'SELECT id FROM test ORDER BY id LIMIT 1'))
-		printf("[003] Persistent connection can still execute queries.");
+		printf("[006] Cannot kill persistent connection, [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+	mysqli_close($plink);
+		
+	if (!$res = mysqli_query($link, 'SHOW FULL PROCESSLIST'))
+		printf("[007] Cannot get processlist, [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+	
+	$running_threads = array();
+	while ($row = mysqli_fetch_assoc($res))
+		$running_threads[$row['Id']] = $row;
+	mysqli_free_result($res);
+	var_dump($running_threads);
+	if (isset($running_threads[$pthread_id]))
+		printf("[008] Thread of the persistent connection should have been gone, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
+		
+	if (!$res = @mysql_query($plink, 'SELECT id FROM test ORDER BY id LIMIT 1'))
+		printf("[009] Persistent connection cannot execute queries, [%d] %s.\n",
mysqli_errno($link), mysqli_error($link));
 	var_dump(mysqli_errno($plink));
 	var_dump(mysqli_error($plink));
-	var_dump(@mysqli_ping($plink));
-		
+	var_dump(@mysqli_ping($plink));	
+	
+	// On PHP side this should do nothing. PHP should not try to close the connection or
something.
+	mysqli_close($plink);
+	
 	if (!$plink = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
-		printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***,
dbname=%s, port=%s, socket=%s\n",
+		printf("[009] Cannot connect to the server using host=%s, user=%s, passwd=***,
dbname=%s, port=%s, socket=%s\n",
 			$host, $user, $db, $port, $socket);
+	if (!$res = mysql_query($plink, 'SELECT id FROM test ORDER BY id LIMIT 1'))
+		printf("[010] New persistent connection cannot execute queries, [%d] %s\n",
mysqli_errno($plink), mysqli_error($plink));
+		
+	mysqli_free_result($res);
 	mysqli_close($plink);
 	mysqli_close($link);
 	print "done!";

Thread
PHP mysqlnd svn commit: r874 - trunk/tests/ext/mysqliuwendel10 Aug