Bug #15772 Aborted YaSSL connections force threads into busyloops
Submitted: 15 Dec 2005 12:59 Modified: 21 Dec 2005 10:38
Reporter: Domas Mituzas
Status: Closed
Category:Server Severity:S1 (Critical)
Version:5.0.15, 5.0.16 OS:Linux (Linux, Solaris 8)
Assigned to: Magnus Blaudd Target Version:

[15 Dec 2005 12:59] Domas Mituzas
Description:
If SSL connection going to a server is aborted, server endlessly tries to read from a
closed socket, and a stale thread is reported in processlist:

strace:
[pid 11844] ioctl(25, FIONREAD, [0])    = 0
[pid 11844] recv(25, "", 1, MSG_PEEK)   = 0
[pid 11844] ioctl(25, FIONREAD, [0])    = 0
[pid 11844] recv(25, "", 1, MSG_PEEK)   = 0
[pid 11844] ioctl(25, FIONREAD, [0])    = 0
[pid 11844] recv(25, "", 1, MSG_PEEK)   = 0
[pid 11844] ioctl(25, FIONREAD, [0])    = 0
[pid 11844] recv(25, "", 1, MSG_PEEK)   = 0

mysql> show processlist;
+----+----------------------+-----------------+------+---------+------+-------+-----------
-------+
| Id | User                 | Host            | db   | Command | Time | State | Info      
      |
+----+----------------------+-----------------+------+---------+------+-------+-----------
-------+
| 34 | unauthenticated user | localhost:59576 | NULL | Connect | NULL | login | NULL      
      |
| 54 | unauthenticated user | localhost:59596 | NULL | Connect | NULL | login | NULL      
      |
| 56 | root                 | localhost:59599 | NULL | Query   |    0 | NULL  | show
processlist |
+----+----------------------+-----------------+------+---------+------+-------+-----------
-------+
3 rows in set (0.00 sec)

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                      
                             
11766 tests     16   0  116m  15m 3840 S 99.9  3.1   3:08.96 mysqld                      

#lsof:
...
mysqld  11766 tests   25u  IPv4    3255053              TCP
localhost:3433->localhost:59576 (CLOSE_WAIT)
...

How to repeat:
Compile MySQL --with-yassl, 

then abort connections of ssl-enabled client:

-- shell script
while true
do
/home/tests/mysql-5.0.16-sslbug/bin/mysql
--defaults-file=/home/tests/mysql-5.0.16-sslbug/ssl/my.cnf -h 127.0.0.1 -P 3433 -e "select
1"
done

Run shell script and abort it several times in order to reproduce behavior. 

Suggested fix:
Check SSL handshake routines
[16 Dec 2005 20:08] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/204
[19 Dec 2005 17:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/267
[20 Dec 2005 0:48] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/271
[20 Dec 2005 12:03] Magnus Blaudd
Pushed to 5.0.18
[21 Dec 2005 10:38] Jon Stephens
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Documented in 5.0.18 changelog. Closed.