Bug #42188 crash and/or memory corruption with user variables in trigger
| Submitted: | 18 Jan 2009 21:39 | Modified: | 11 Feb 2009 3:39 |
|---|---|---|---|
| Reporter: | Frederic Steinfels | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Stored Routines | Severity: | S1 (Critical) |
| Version: | 5.1.29, 5.1.30, 5.1.31, 6.0.8, 6.0.10 | OS: | Any |
| Assigned to: | Gleb Shchepa | CPU Architecture: | Any |
| Tags: | corruption, crash, mysql_change_user, regression, stored procedure, trigger | ||
[18 Jan 2009 21:39]
Frederic Steinfels
[19 Jan 2009 15:12]
Frederic Steinfels
I have been able to track down the problem to the usage of @ variables in stored procedures. When replacing this with local variables read/written from/to tables, everything goes well. When using @ variables, MySQL will crash.
[19 Jan 2009 18:07]
Shane Bester
testcase. run against mysqld-debug or mysqld under valgrind if crashes don't happen soon
Attachment: bug42188.c (text/plain), 6.96 KiB.
[19 Jan 2009 18:16]
Shane Bester
this is a recent regression introduced in 5.1.29 afaict.
[21 Jan 2009 5:43]
Gleb Shchepa
Small test case is: CREATE TABLE t1 (i INT); CREATE TRIGGER t_after_insert AFTER INSERT ON t1 FOR EACH ROW SET @bug42188 = 10; INSERT INTO t1 VALUES (1); --change_user INSERT INTO t1 VALUES (1); DROP TABLE t1; mysql_change_user() API call forces TDH::cleanup() call that frees user variable entries, however it doesn't reset Item_func_set_user_var::entry to NULL because Item_func_set_user_var::cleanup() is not overloaded. So, Item_func_set_user_var::entry holds a pointer to freed memory, this causes a crash.
[21 Jan 2009 6:14]
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/63656 2748 Gleb Shchepa 2009-01-21 Bug#42188: crash and/or memory corruption with user variables in trigger Interchangeable calls to the mysql_change_user client function and invocations of a trigger changing some user variable caused a memory corruption and a crash. The mysql_change_user API call forces TDH::cleanup() on a server that frees user variable entries. However it didn't reset Item_func_set_user_var::entry to NULL because Item_func_set_user_var::cleanup() was not overloaded. So, Item_func_set_user_var::entry held a pointer to freed memory, that caused a crash. The Item_func_set_user_var::cleanup method has been overloaded to cleanup the Item_func_set_user_var::entry field.
[24 Jan 2009 14:11]
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/63980 2746 Gleb Shchepa 2009-01-24 Bug #42188: After-push test file update (see bug 42321)
[3 Feb 2009 9:41]
Bugs System
Pushed into 5.1.32 (revid:joro@sun.com-20090203090549-gos3v4320vimrzg6) (version source revid:gshchepa@mysql.com-20090124140710-17brta8t95ds3xfy) (merge vers: 5.1.32) (pib:6)
[4 Feb 2009 11:17]
Bugs System
Pushed into 6.0.10-alpha (revid:kostja@sun.com-20090204104420-mw1i2u9lum4bxjo6) (version source revid:gshchepa@mysql.com-20090124142202-badofkubjngzuo4r) (merge vers: 6.0.10-alpha) (pib:6)
[11 Feb 2009 3:39]
Paul DuBois
Noted in 5.1.32, 6.0.10 changelog. User variables within triggers could cause a crash if the mysql_change_user() C API function was invoked.
[17 Feb 2009 15:01]
Bugs System
Pushed into 5.1.32-ndb-6.3.23 (revid:tomas.ulin@sun.com-20090217131017-6u8qz1edkjfiobef) (version source revid:tomas.ulin@sun.com-20090203133556-9rclp06ol19bmzs4) (merge vers: 5.1.32-ndb-6.3.22) (pib:6)
[17 Feb 2009 16:48]
Bugs System
Pushed into 5.1.32-ndb-6.4.3 (revid:tomas.ulin@sun.com-20090217134419-5ha6xg4dpedrbmau) (version source revid:tomas.ulin@sun.com-20090203133556-9rclp06ol19bmzs4) (merge vers: 5.1.32-ndb-6.3.22) (pib:6)
[17 Feb 2009 18:24]
Bugs System
Pushed into 5.1.32-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090217134216-5699eq74ws4oxa0j) (version source revid:tomas.ulin@sun.com-20090202111723-1zzwax187rtls913) (merge vers: 5.1.32-ndb-6.2.17) (pib:6)
[19 Feb 2009 8:20]
Valeriy Kravchuk
Bug #42975 was marked as a duplicate of this one.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.080 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.