Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-8014

[PATCH] MariaDB client can hang in an infinite loop

    XMLWordPrintable

Details

    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.

      Attachments

        Activity

          People

            serg Sergei Golubchik
            pivanof Pavel Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.