List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:February 26 2008 3:04pm
Subject:bk commit into 5.1 tree (davi:1.2580) BUG#34424
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of davi.  When davi does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-02-26 12:03:59-03:00, davi@stripped +7 -0
  Bug#34424 query_cache_debug.test leads to valgrind warnings
  Bug#34678 @@debug variable's incremental mode
  
  The problem is that the per-thread debugging settings stack wasn't
  being deallocated before the thread termination, leaking the stack
  memory. The chosen solution is to push a new state if the current
  is set to the initial settings and pop it (free) once the thread
  finishes.

  dbug/dbug.c@stripped, 2008-02-26 12:03:56-03:00, davi@stripped +35 -10
    Move dbug parser out of _db_set_ to a separate function and
    make _db_set_ push a new stack if the corrent one is set to
    the initial settings.

  dbug/user.r@stripped, 2008-02-26 12:03:56-03:00, davi@stripped +3 -2
    Update DBUG_SET description.

  mysql-test/r/variables_debug.result@stripped, 2008-02-26 12:03:57-03:00, davi@stripped +12 -0
    Add new test case result for Bug#34678

  mysql-test/r/variables_debug.result@stripped, 2008-02-26 12:03:57-03:00, davi@stripped +0 -0

  mysql-test/t/disabled.def@stripped, 2008-02-26 12:03:56-03:00, davi@stripped +0 -1
    Re-enable test case which triggered the leak.

  mysql-test/t/variables_debug.test@stripped, 2008-02-26 12:03:57-03:00, davi@stripped +12 -0
    Add new test case for Bug#34678

  mysql-test/t/variables_debug.test@stripped, 2008-02-26 12:03:57-03:00, davi@stripped +0 -0

  mysys/my_thr_init.c@stripped, 2008-02-26 12:03:56-03:00, davi@stripped +1 -0
    Pop a pushed state, nop if stack is empty.

  sql/set_var.cc@stripped, 2008-02-26 12:03:56-03:00, davi@stripped +2 -4
    Handle incremental debug settings.

diff -Nrup a/dbug/dbug.c b/dbug/dbug.c
--- a/dbug/dbug.c	2007-10-15 14:56:22 -02:00
+++ b/dbug/dbug.c	2008-02-26 12:03:56 -03:00
@@ -412,15 +412,11 @@ void _db_process_(const char *name)
   cs->process= name;
 }
 
+
 /*
  *  FUNCTION
  *
- *      _db_set_       set current debugger settings
- *
- *  SYNOPSIS
- *
- *      VOID _db_set_(control)
- *      char *control;
+ *      DbugParse       parse control string and set current debugger setting
  *
  *  DESCRIPTION
  *
@@ -444,7 +440,7 @@ void _db_process_(const char *name)
  *
  */
 
-void _db_set_(CODE_STATE *cs, const char *control)
+static void DbugParse(CODE_STATE *cs, const char *control)
 {
   const char *end;
   int rel=0;
@@ -674,6 +670,35 @@ void _db_set_(CODE_STATE *cs, const char
 /*
  *  FUNCTION
  *
+ *      _db_set_       set current debugger settings
+ *
+ *  SYNOPSIS
+ *
+ *      VOID _db_set_(control)
+ *      char *control;
+ *
+ *  DESCRIPTION
+ *
+ *      Given pointer to a debug control string in "control",
+ *      parses the control string, and sets up a current debug
+ *      settings. Pushes a new debug settings if the current is
+ *      set to the initial debugger settings.
+ */
+
+void _db_set_(CODE_STATE *cs, const char *control)
+{
+  get_code_state_or_return;
+
+  if (cs->stack == &init_settings)
+    PushState(cs);
+
+  DbugParse(cs, control);
+}
+
+
+/*
+ *  FUNCTION
+ *
  *      _db_push_       push current debugger settings and set up new one
  *
  *  SYNOPSIS
@@ -685,7 +710,7 @@ void _db_set_(CODE_STATE *cs, const char
  *
  *      Given pointer to a debug control string in "control", pushes
  *      the current debug settings, parses the control string, and sets
- *      up a new debug settings with _db_set_()
+ *      up a new debug settings with DbugParse()
  *
  */
 
@@ -694,7 +719,7 @@ void _db_push_(const char *control)
   CODE_STATE *cs=0;
   get_code_state_or_return;
   PushState(cs);
-  _db_set_(cs, control);
+  DbugParse(cs, control);
 }
 
 /*
@@ -717,7 +742,7 @@ void _db_set_init_(const char *control)
   CODE_STATE tmp_cs;
   bzero((uchar*) &tmp_cs, sizeof(tmp_cs));
   tmp_cs.stack= &init_settings;
-  _db_set_(&tmp_cs, control);
+  DbugParse(&tmp_cs, control);
 }
 
 /*
diff -Nrup a/dbug/user.r b/dbug/user.r
--- a/dbug/user.r	2007-01-28 18:11:39 -02:00
+++ b/dbug/user.r	2008-02-26 12:03:56 -03:00
@@ -730,8 +730,9 @@ warning will be given.  The DBUG_POP mac
 EX:\ \fCDBUG_POP\ ();\fR
 .SP 1
 .LI DBUG_SET\ 
-Modifies the current debugger state on top of the stack using the
-debug control string passed as the macro argument.  Unless
+Modifies the current debugger state on top of the stack or pushes
+a new state if the current is set to the initial settings, using
+the debug control string passed as the macro argument.  Unless
 .I incremental
 control string is used (see below), it's equivalent to a combination of
 DBUG_POP and DBUG_PUSH.
diff -Nrup a/mysql-test/r/variables_debug.result b/mysql-test/r/variables_debug.result
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/r/variables_debug.result	2008-02-26 12:03:57 -03:00
@@ -0,0 +1,12 @@
+set debug= 'T';
+select @@debug;
+@@debug
+T
+set debug= '+P';
+select @@debug;
+@@debug
+P:T
+set debug= '-P';
+select @@debug;
+@@debug
+T
diff -Nrup a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
--- a/mysql-test/t/disabled.def	2008-02-22 11:26:06 -03:00
+++ b/mysql-test/t/disabled.def	2008-02-26 12:03:56 -03:00
@@ -22,4 +22,3 @@ wait_timeout         : Bug#32801 wait_ti
 ctype_create         : Bug#32965 main.ctype_create fails
 status               : Bug#32966 main.status fails
 ps_ddl               : Bug#12093 2007-12-14 pending WL#4165 / WL#4166
-query_cache_debug    : Bug#34424: query_cache_debug.test leads to valgrind warnings
diff -Nrup a/mysql-test/t/variables_debug.test b/mysql-test/t/variables_debug.test
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/t/variables_debug.test	2008-02-26 12:03:57 -03:00
@@ -0,0 +1,12 @@
+--source include/have_debug.inc
+
+#
+# Bug#34678 @@debug variable's incremental mode
+#
+
+set debug= 'T';
+select @@debug;
+set debug= '+P';
+select @@debug;
+set debug= '-P';
+select @@debug;
diff -Nrup a/mysys/my_thr_init.c b/mysys/my_thr_init.c
--- a/mysys/my_thr_init.c	2007-08-21 13:09:43 -03:00
+++ b/mysys/my_thr_init.c	2008-02-26 12:03:56 -03:00
@@ -332,6 +332,7 @@ void my_thread_end(void)
     /* tmp->dbug is allocated inside DBUG library */
     if (tmp->dbug)
     {
+      DBUG_POP();
       free(tmp->dbug);
       tmp->dbug=0;
     }
diff -Nrup a/sql/set_var.cc b/sql/set_var.cc
--- a/sql/set_var.cc	2008-02-08 14:33:19 -02:00
+++ b/sql/set_var.cc	2008-02-26 12:03:56 -03:00
@@ -3926,10 +3926,8 @@ bool sys_var_thd_dbug::update(THD *thd, 
   if (var->type == OPT_GLOBAL)
     DBUG_SET_INITIAL(var ? var->value->str_value.c_ptr() : "");
   else
-  {
-    DBUG_POP();
-    DBUG_PUSH(var ? var->value->str_value.c_ptr() : "");
-  }
+    DBUG_SET(var ? var->value->str_value.c_ptr() : "");
+
   return 0;
 }
 
Thread
bk commit into 5.1 tree (davi:1.2580) BUG#34424Davi Arnaut26 Feb