Bug #46165 | server crash in dbug | ||
---|---|---|---|
Submitted: | 14 Jul 2009 10:51 | Modified: | 30 Dec 2012 10:17 |
Reporter: | Ingo Strüwing | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Logging | Severity: | S1 (Critical) |
Version: | azalea | OS: | Linux |
Assigned to: | Jon Olav Hauglid | CPU Architecture: | Any |
[14 Jul 2009 10:51]
Ingo Strüwing
[14 Jul 2009 12:33]
Ingo Strüwing
Suggested triage values: Defact: critical. Server crash. Workaround: partial. A different sequence might avoid the crash. Impact: minimal. Uncommon use of the debug variable.
[15 Apr 2010 13:37]
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/105746 3018 Jon Olav Hauglid 2010-04-15 Bug #46165 server crash in dbug This crash occured if the "debug" server system variable was used in the following way: 1) Enable debug tracing to a logfile (global scope) 2) Enable debug tracing to the same logfile (session scope) 3) Change debug settings (global scope) 4) Change debug settings (session scope) This caused a crash because the logfile was, by mistake, closed in 3), leading to the same memory being free'd twice when the file was closed again in 4). Internally, the debug settings are stored in a stack, with the current (last set) settings on top. When a set of settings is changed, it must be determined if the debug logfile is to be closed. Before this was done by only checking below on the settings stack. So if the set of settings to be changed was not on top of the stack, an existing debug logfile reference could be missed. This caused the file to be closed even if it was in use, leading to a crash later when it was closed again. In this case, at point 3) the session settings were at the top of the settings stack, with the global settings below. Since 3) changed the global settings, the sessions settings were not checked and the other file reference was missed. The file was therefore closed by mistake. This patch fixes the problem by making the stack double-linked so that settings above the settings to be changed, can be checked for logfile references. Test case added to variables.test.
[28 Apr 2010 9:33]
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/106770 3008 Jon Olav Hauglid 2010-04-28 Bug #46165 server crash in dbug This crash occured if the same debug trace file was closed twice, leading to the same memory being free'd twice. This could occur if the "debug" server system variable refered to the same trace file in both global and session scope. Example of an order of events that would lead to a crash: 1) Enable debug tracing to a trace file (global scope) 2) Enable debug tracing to the same trace file (session scope) 3) Reset debug settings (global scope) 4) Reset debug settings (session scope) This caused a crash because the trace file was, by mistake, closed in 3), leading to the same memory being free'd twice when the file was closed again in 4). Internally, the debug settings are stored in a stack, with session settings (if any) on top and the global settings below. Each connection has its own stack. When a set of settings is changed, it must be determined if its debug trace file is to be closed. Before, this was done by only checking below on the settings stack. So if the global settings were changed, an existing debug trace file reference in session settings would be missed. This caused the file to be closed even if it was in use, leading to a crash later when it was closed again. This patch fixes the problem by using reference counting to keep track of when it is safe to close a given debug trace file. Test case added to variables.test.
[28 Sep 2010 9:09]
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/119237 3146 Jon Olav Hauglid 2010-09-28 Bug #46165 server crash in dbug This crash occured if the same debug trace file was closed twice, leading to the same memory being free'd twice. This could occur if the "debug" server system variable refered to the same trace file in both global and session scope. Example of an order of events that would lead to a crash: 1) Enable debug tracing to a trace file (global scope) 2) Enable debug tracing to the same trace file (session scope) 3) Reset debug settings (global scope) 4) Reset debug settings (session scope) This caused a crash because the trace file was, by mistake, closed in 3), leading to the same memory being free'd twice when the file was closed again in 4). Internally, the debug settings are stored in a stack, with session settings (if any) on top and the global settings below. Each connection has its own stack. When a set of settings is changed, it must be determined if its debug trace file is to be closed. Before, this was done by only checking below on the settings stack. So if the global settings were changed, an existing debug trace file reference in session settings would be missed. This caused the file to be closed even if it was in use, leading to a crash later when it was closed again. This patch fixes the problem by preventing the trace file from being shared between global and session settings. If session debug settings are set without specifying a new trace file, stderr is used for output. This is a change in behaviour and should be reflected in the documentation. Test case added to variables.test.
[28 Sep 2010 12:23]
Jon Olav Hauglid
Pushed to mysql-5.5-runtime (5.5.7-m3).
[29 Sep 2010 8:10]
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/119349 3147 Jon Olav Hauglid 2010-09-29 Followup to Bug#46165 server crash in dbug This patch moves the regression test from variables.test to variables_debug.test as the debug system variable is not available on release builds.
[4 Nov 2010 1:33]
Paul DuBois
Noted in 5.5.7 changelog. If the global and session debug system variables had the same value, the debug trace file could be closed twice, leading to freeing already freed memory and a server crash.
[9 Nov 2010 19:48]
Bugs System
Pushed into mysql-5.5 5.5.7-rc (revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (version source revid:marko.makela@oracle.com-20100824081003-v4ecy0tga99cpxw2) (merge vers: 5.1.50) (pib:21)
[13 Nov 2010 16:09]
Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:marko.makela@oracle.com-20100824081003-v4ecy0tga99cpxw2) (merge vers: 5.1.50) (pib:21)
[13 Nov 2010 16:39]
Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:marko.makela@oracle.com-20100824081003-v4ecy0tga99cpxw2) (pib:21)
[26 Apr 2011 12:42]
Mikael Ronström
The bug fix solved the bug but introduced a new one. The idea when using the command: SET SESSION debug="+d,enter,info,exit,error,query,make_query_very_long" is to add more keywords to the debug tracing. However the patch has the nasty side effect of redirecting all trace output to stderr thus making it impossible to use DBUG_EXECUTE_IF in conjunction with DBUG tracing. This makes it impossible to trace many of the important mysql-test-run scripts.
[30 Dec 2012 10:17]
MySQL Verification Team
This was fixed in 5.5.7.