mariadb/dbug
Jon Olav Hauglid 92b247814a 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.
2010-09-28 11:07:58 +02:00
..
CMakeLists.txt Patch for Bug#55854 (MySQL AB should not be AUTHOR, copyright incorrect). 2010-08-12 19:19:57 +04:00
dbug.c Bug #46165 server crash in dbug 2010-09-28 11:07:58 +02:00
dbug_add_tags.pl backport of dbug extensions from 6.0: 2009-10-30 19:13:58 +01:00
dbug_analyze.c WL#5486: Remove code for unsupported platforms 2010-07-15 08:16:06 -03:00
dbug_long.h dbug: DBUG_EXECUTE_IF macro, build user manual automatically, document all features 2004-11-04 22:29:00 +01:00
example1.c document DBUG_OUTPUT() 2004-11-11 14:42:35 +01:00
example2.c document DBUG_OUTPUT() 2004-11-11 14:42:35 +01:00
example3.c document DBUG_OUTPUT() 2004-11-11 14:42:35 +01:00
factorial.c Bug#26243 mysql command line crash after control-c 2008-03-28 14:02:27 -04:00
main.c document DBUG_OUTPUT() 2004-11-11 14:42:35 +01:00
Makefile.am Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
monty.doc dbug changes: 2006-02-14 22:36:11 +01:00
my_main.c Several fixes revelaled by Intel compiler. 2005-09-23 16:47:08 +03:00
remove_function_from_trace.pl backport of dbug extensions from 6.0: 2009-10-30 19:13:58 +01:00
tests-t.pl backport of dbug extensions from 6.0: 2009-10-30 19:13:58 +01:00
tests.c backport of dbug extensions from 6.0: 2009-10-30 19:13:58 +01:00
user.r Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00