| Bug #33982 | debug assertion and crash reloading grant tables after sighup or kill | ||
|---|---|---|---|
| Submitted: | 22 Jan 2008 15:11 | Modified: | 17 Jun 2010 22:51 | 
| Reporter: | Shane Bester (Platinum Quality Contributor) | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Security: Privileges | Severity: | S2 (Serious) | 
| Version: | 5.1.24-bk-debug, 5.1.37-debug, 6.0 | OS: | Any | 
| Assigned to: | Kristofer Pettersson | CPU Architecture: | Any | 
| Tags: | assertion, KILL | ||
   [22 Jan 2008 15:11]
   Shane Bester        
  
 
   [1 Feb 2008 14:01]
   Philip Stoev        
  This also happens on 6.0.4. The following steps are sufficient, replication does not have to be enabled: 1. Compile a debug binary 2. Run mysql-test-run.pl --start-and-exit --skip-ndb 3. kill -HUP the mysqld
   [7 Jul 2009 7:24]
   MySQL Verification Team        
  killing flush privileges causes a debug assertion and crash:
Stack from 5.1.37-debug
Assertion failed: m_status == DA_ERROR || m_status == DA_OK, file e:\builds\bzr\5.1\sql\sql_class.h, line 1146
090707  9:21:03 - mysqld got exception 0x80000003 ;
mysqld.exe!_NMSG_WRITE()[crt0msg.c:198]
mysqld.exe!abort()[abort.c:59]
mysqld.exe!_wassert()[assert.c:212]
mysqld.exe!Diagnostics_area::message()[sql_class.h:1146]
mysqld.exe!servers_reload()[sql_servers.cc:245]
mysqld.exe!reload_acl_and_cache()[sql_parse.cc:6768]
mysqld.exe!mysql_execute_command()[sql_parse.cc:3944]
mysqld.exe!sp_instr_stmt::exec_core()[sp_head.cc:2907]
mysqld.exe!sp_lex_keeper::reset_lex_and_exec_core()[sp_head.cc:2735]
mysqld.exe!sp_instr_stmt::execute()[sp_head.cc:2849]
mysqld.exe!sp_head::execute()[sp_head.cc:1253]
mysqld.exe!sp_head::execute_procedure()[sp_head.cc:1983]
mysqld.exe!mysql_execute_command()[sql_parse.cc:4354]
mysqld.exe!mysql_parse()[sql_parse.cc:5933]
mysqld.exe!dispatch_command()[sql_parse.cc:1213]
mysqld.exe!do_command()[sql_parse.cc:854]
mysqld.exe!handle_one_connection()[sql_connect.cc:1127]
mysqld.exe!pthread_start()[my_winthread.c:85]
mysqld.exe!_callthreadstart()[thread.c:293]
mysqld.exe!_threadstart()[thread.c:277]
kernel32.dll!FlsSetValue()
t some variables.
s may be invalid and cause the dump to abort...
t 05ECED68=flush privileges
id=5
KILL_CONNECTION
testcase:
delimiter ;
drop procedure if exists `p1`;
delimiter //
create procedure `p1`(`numusers` int)
begin
 declare `i` int default '0';
 
 repeat
   flush privileges;
   set @q=concat('grant all on *.* to user',`i`);
   prepare `stmt` from @q;
   execute `stmt`;
   deallocate prepare `stmt`;
   set `i`=`i`+1;
 until `i`>`numusers`
 end repeat;
end//
delimiter ;
call `p1`(5000);  #open another connection and kill this query. repeat until crash.
 
   [13 Jul 2009 8:12]
   Sveta Smirnova        
  Thank you for the report. Verified as described: Version: '5.1.37-debug' socket: '/tmp/mysql51.sock' port: 3351 Source distribution sql_class.h:1146: failed assertion `m_status == DA_ERROR || m_status == DA_OK' 090713 12:09:37 - mysqld got signal 6 ; Test I used: while true; do mysql -b --socket=/tmp/mysql51.sock -uroot test -e "call p1(5000);"; done then typed Ctrl+C until server crashes.
   [16 Jul 2009 10:22]
   Konstantin Osipov        
  Kristoffer, this is most likely a duplicate of Bug#44521. Could you please verify that and close if it's the case?
   [13 Jan 2010 11:39]
   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/96737 3303 Kristofer Pettersson 2010-01-13 Bug#33982 debug assertion and crash reloading grant tables after sighup or kill In certain rare cases when a process was interrupted during a FLUSH PRIVILEGES operation the diagnostic area would be set to an error state but the function responsible for the operation would still signal success. This would lead to a debug assertion error later on when the server would attempt to reset the DA before sending the error message. This patch fixes the issue by assuring that reload_acl_and_cache() always fails if an error condition is raised. The second issue was that a KILL could cause a console error message which referred to a DA state without first making sure that such a state existed. This patch fixes this issue in two different palces by first checking DA state before fetching the error message. @ sql/sql_acl.cc * Make sure that there is an error to print before attempting to do so. * Minor style change: change 1 to TRUE for clarity. @ sql/sql_parse.cc * Always fail reload_acl_and_cache() if the query was killed. @ sql/sql_servers.cc * Make sure that there is an error to print before attempting to do so.
   [5 Feb 2010 11:47]
   Bugs System        
  Pushed into mysql-next-mr (revid:alik@sun.com-20100204063540-9czpdmpixi3iw2yb) (version source revid:alik@sun.com-20100119163614-172adculixyu26j5) (pib:16)
   [5 Feb 2010 11:53]
   Bugs System        
  Pushed into 6.0.14-alpha (revid:alik@sun.com-20100205113942-oqovjy0eoqbarn7i) (version source revid:alik@sun.com-20100204064210-ljwanqvrjs83s1gq) (merge vers: 6.0.14-alpha) (pib:16)
   [5 Feb 2010 11:59]
   Bugs System        
  Pushed into 5.5.2-m2 (revid:alik@sun.com-20100203172258-1n5dsotny40yufxw) (version source revid:alexey.kopytov@sun.com-20100115112653-e3a24041ag1cv6v3) (merge vers: 5.5.1-m2) (pib:16)
   [10 Feb 2010 19:18]
   Paul DuBois        
  Noted in 5.5.2, 6.0.14 changelogs. 1) In rare cases, if a thread was interrupted during a FLUSH PRIVILEGES operation, a debug assertion occurred later due to improper diagnostic area setup. 2) A KILL operation could cause a console error message referring to a diagnostic area state without first ensuring that the state existed. Setting report to Need Merge pending push to Celosia.
   [12 Mar 2010 14:07]
   Bugs System        
  Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
   [12 Mar 2010 14:23]
   Bugs System        
  Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
   [12 Mar 2010 14:37]
   Bugs System        
  Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)
   [12 Mar 2010 17:58]
   Paul DuBois        
  Noted in -ndb- changelogs.
   [12 Apr 2010 10:16]
   Bugs System        
  Pushed into 5.1.47 (revid:build@mysql.com-20100412101220-adgau1r18kwgthps) (version source revid:build@mysql.com-20100412101220-adgau1r18kwgthps) (merge vers: 5.1.47) (pib:16)
   [12 Apr 2010 14:03]
   Paul DuBois        
  Noted in 5.1.47 changelog.
   [28 May 2010 6:06]
   Bugs System        
  Pushed into mysql-next-mr (revid:alik@sun.com-20100524190136-egaq7e8zgkwb9aqi) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (pib:16)
   [28 May 2010 6:34]
   Bugs System        
  Pushed into 6.0.14-alpha (revid:alik@sun.com-20100524190941-nuudpx60if25wsvx) (version source revid:alik@sun.com-20100422150658-fkhgnwwkyugtxrmu) (merge vers: 6.0.14-alpha) (pib:16)
   [28 May 2010 7:02]
   Bugs System        
  Pushed into 5.5.5-m3 (revid:alik@sun.com-20100524185725-c8k5q7v60i5nix3t) (version source revid:alexey.kopytov@sun.com-20100429203306-tg0wz4y2xyx8edrl) (merge vers: 5.5.5-m3) (pib:16)
   [30 May 2010 1:08]
   Paul DuBois        
  Already fixed.
   [17 Jun 2010 12:10]
   Bugs System        
  Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
   [17 Jun 2010 12:58]
   Bugs System        
  Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
   [17 Jun 2010 13:38]
   Bugs System        
  Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
