Bug #28582 event_scheduler uses uninitialized variable in show processlist 'info' output
Submitted: 22 May 2007 8:34 Modified: 30 Jun 2007 20:26
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S1 (Critical)
Version:5.1.19 OS:Any
Assigned to: Georgi Kodinov CPU Architecture:Any

[22 May 2007 8:34] Shane Bester
Description:
When the event scheduler runs, there is sometimes corruption in the processlist output.  See an example:

mysql> select * from processlist where user='event_scheduler'\G
*************************** 1. row ***************************
     ID: 290
   USER: event_scheduler
   HOST: localhost
     DB: test
COMMAND: Connect
   TIME: 4
  STATE: NULL
   INFO: C:\DOCUME~1\ADMINI~1\LOCALS
*************************** 2. row ***************************
     ID: 289
   USER: event_scheduler
   HOST: localhost
     DB: test
COMMAND: Connect
   TIME: 6
  STATE: NULL
   INFO:
*************************** 3. row ***************************
     ID: 1
   USER: event_scheduler
   HOST: localhost
     DB: NULL
COMMAND: Daemon
   TIME: 4
  STATE: NULL
   INFO: NULL
3 rows in set, 1 warning (0.09 sec)

mysql> show warnings;
+---------+------+-------------------------------------------------------------------------------+
| Level   | Code | Message                                                                       |
+---------+------+-------------------------------------------------------------------------------+
| Warning | 1366 | Incorrect string value: '\xC8\xDF#\x0E\x00\x00...' for column 'INFO' at row 1 |
+---------+------+-------------------------------------------------------------------------------+
1 row in set (0.02 sec)

show full processlist also contains entries like this:

     Id: 315
   User: event_scheduler
   Host: localhost
     db: test
Command: Connect
   Time: 8
  State: NULL
   Info: ???????????????????????????

How to repeat:
I will upload a testcase later.

Suggested fix:
find the uninitialized variable.  fix the potential crash.
[22 May 2007 8:59] MySQL Verification Team
testcase. see top of file for compile example, host, user, password

Attachment: bug28582.c (text/plain), 6.26 KiB.

[22 May 2007 9:00] MySQL Verification Team
Run the testcase,  which examines the processlist and finds what appears to be corrupted values by looking at the warnings returned.

Example output on linux:

sbester@www:~> gcc bug28582.c -g -o bug28582 -L/home/sbester/server/5.1/mysql-5.1.19-beta-linux-i686/lib -I/home/sbester/server/5.1/mysql-5.1.19-beta-linux-i686/include   -lmysqlclient_r -lz -lpthread
sbester@www:~> ./bug28582 
running initializations..
pre-generating 16777216 bytes of random data
about to spawn 10 threads
..........
completed spawning new database worker threads
testcase is now running, so watch for error output
found corruption!
Level   Code    Message
------------------------------------
Warning 1366    Incorrect string value: '\xB8\x1D@NT ...' for column 'INFO' at row 1

found corruption!
found corruption!
Level   Code    Message
------------------------------------
Warning 1366    Incorrect string value: '\xB8\x1D@NT ...' for column 'INFO' at row 1
[25 Jun 2007 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[30 Jun 2007 20:26] MySQL Verification Team
I confirm this is not repeatable on 5.1.21BK anymore.
[1 Jul 2010 19:59] Bassam Tabbara
I am seeing this with MySql 5.1.47 on debian lenny x64.

mysql> select * from information_schema.processlist where user='event_scheduler';
+----+-----------------+-----------+------+---------+------+-----------------------------+------+----------+
| ID | USER            | HOST      | DB   | COMMAND | TIME | STATE                       | INFO | TIME_MS  |
+----+-----------------+-----------+------+---------+------+-----------------------------+------+----------+
|  1 | event_scheduler | localhost | NULL | Daemon  |   13 | Waiting for next activation | NULL | 38771078 |
+----+-----------------+-----------+------+---------+------+-----------------------------+------+----------+
1 row in set, 1 warning (0.01 sec)

mysql> show warnings;
+---------+------+-------------------------------------------------------------------+
| Level   | Code | Message                                                           |
+---------+------+-------------------------------------------------------------------+
| Warning | 1366 | Incorrect string value: '\x86M\0\0...' for column 'INFO' at row 1 |
+---------+------+-------------------------------------------------------------------+
1 row in set (0.00 sec)

Here is a really simple repro:

DELIMITER $$

DROP EVENT IF EXISTS `TestEvent`
$$

CREATE EVENT `TestEvent` ON SCHEDULE EVERY 15 SECOND
DO BEGIN
    SELECT COUNT(*) FROM information_schema.PROCESSLIST;
END;
$$