Bug #84555 memory corruption when attempting to delete from renamed old general_log table
Submitted: 18 Jan 2017 14:32 Modified: 18 Jan 2017 16:47
Reporter: Chris Duffin Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.6.30 OS:CentOS
Assigned to: CPU Architecture:Any

[18 Jan 2017 14:32] Chris Duffin
Description:
After disabling the general log and renaming the general_log table to something else, I attempted to delete rows not matching a specific criteria. When attempting to do so, MySQL threw a memory corruption error from the malloc call. Full backtrace attached.

How to repeat:
Disable general log:
SET GLOBAL general_log = 'OFF';

Rename general log table to something else:
RENAME TABLE general_log TO general_log_temp;

Attempt to delete data from the table:
delete from general_log_temp where argument not like "call ui_%";
[18 Jan 2017 16:47] MySQL Verification Team
Hi!

I have tried to repeat your bug, with no avail. I tried using both CSV and MyISAM engines and result is the same both times. I have  used the settings that you stipulated and here are the results:

mysql> select * from mysql.general_log;
+---------------------+-------------------------+-----------+-----------+--------------+---------------------------------------------------------+
| event_time          | user_host               | thread_id | server_id | command_type | argument                                                |
+---------------------+-------------------------+-----------+-----------+--------------+---------------------------------------------------------+
| 2017-01-18 18:37:52 | [sinisa] @ localhost [] |         1 |         0 | Connect      | sinisa@localhost as  on sinbas                          |
| 2017-01-18 18:37:52 | [sinisa] @ localhost [] |         1 |         0 | Query        | show databases                                          |
| 2017-01-18 18:37:52 | [sinisa] @ localhost [] |         1 |         0 | Query        | show tables                                             |
| 2017-01-18 18:37:52 | [sinisa] @ localhost [] |         1 |         0 | Field List   | proc                                                    |
| 2017-01-18 18:37:52 | [sinisa] @ localhost [] |         1 |         0 | Field List   | ps_category                                             |
| 2017-01-18 18:37:52 | [sinisa] @ localhost [] |         1 |         0 | Field List   | ps_category_product                                     |
| 2017-01-18 18:37:52 | [sinisa] @ localhost [] |         1 |         0 | Field List   | ps_product_shop                                         |
| 2017-01-18 18:37:52 | [sinisa] @ localhost [] |         1 |         0 | Field List   | t1                                                      |
| 2017-01-18 18:37:52 | [sinisa] @ localhost [] |         1 |         0 | Field List   | t2                                                      |
| 2017-01-18 18:37:52 | [sinisa] @ localhost [] |         1 |         0 | Query        | select @@version_comment limit 1                        |
| 2017-01-18 18:38:21 | [sinisa] @ localhost [] |         1 |         0 | Query        | select * from proc                                      |
| 2017-01-18 18:38:25 | [sinisa] @ localhost [] |         1 |         0 | Query        | show tables                                             |
| 2017-01-18 18:38:36 | [sinisa] @ localhost [] |         1 |         0 | Query        | select * from ps_category limit 1                       |
| 2017-01-18 18:38:45 | [sinisa] @ localhost [] |         1 |         0 | Query        | select * from ps_category_product limit 1               |
| 2017-01-18 18:38:59 | [sinisa] @ localhost [] |         1 |         0 | Query        | select * from ps_product_shop limit 1                   |
| 2017-01-18 18:39:07 | [sinisa] @ localhost [] |         1 |         0 | Query        | select * from t1                                        |
| 2017-01-18 18:39:58 | [sinisa] @ localhost [] |         1 |         0 | Query        | update ps_product_shop set id_shop=2 where id_product=1 |
| 2017-01-18 18:40:04 | [sinisa] @ localhost [] |         1 |         0 | Query        | update ps_product_shop set id_shop=1 where id_product=1 |
| 2017-01-18 18:40:22 | [sinisa] @ localhost [] |         1 |         0 | Query        | select * from mysql.general_log                         |
+---------------------+-------------------------+-----------+-----------+--------------+---------------------------------------------------------+
19 rows in set (0.00 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> set global general_log=OFF;
Query OK, 0 rows affected (0.04 sec)

mysql> RENAME TABLE general_log TO general_log_temp;
Query OK, 0 rows affected (0.00 sec)

mysql> delete from general_log_temp where argument not like "select %";
Query OK, 46 rows affected (0.01 sec)
[18 Jan 2017 17:19] MySQL Verification Team
Just for further info. I test this on 5.6.17, 5.6.30, 5.7.10 and 5.7.15 and it all worked just fine .....