Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.0.17, 5.5(EOL), 10.0(EOL), 10.1(EOL)
Description
In certain conditions MySQL client compiled from MariaDB sources can hang in an infinite loop.
The problem is in my_real_read() function in sql/net_serv.cc. When vio_read() returns 0 that means EOF. But it's processed as if it's error and gets to the following lines:
#ifndef MYSQL_SERVER
|
if (vio_errno(net->vio) == SOCKET_EINTR)
|
{
|
DBUG_PRINT("warning",("Interrupted read. Retrying..."));
|
continue;
|
}
|
#endif
|
Note that EOF is not an error and thus recv() doesn't change errno when it returns 0. So errno contains whatever last erroneous syscall set in there. And if it contains EINTR then the code goes to the beginning of the loop, calls vio_read() again which returns 0 again, and it goes into the same "if" again, goes to the beginning of the loop etc.
Simple adding of "length != 0 && " to the beginning of this "if" condition should fix the problem.
The bug affects 5.5, 10.0 and 10.1.
Note that upstream MySQL has this commit https://github.com/mysql/mysql-server/commit/1936d72 which changed a lot of the code and re-wrote this part in a way that doesn't have this bug.