[MDEV-8014] [PATCH] MariaDB client can hang in an infinite loop Created: 2015-04-18  Updated: 2015-05-05  Resolved: 2015-05-05

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.0.17, 5.5, 10.0, 10.1
Fix Version/s: 10.0.18, 10.1.5

Type: Bug Priority: Major
Reporter: Pavel Ivanov Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: upstream-fixed


 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.


Generated at Thu Feb 08 07:24:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.