#At file:///export/home/tmp/olav/bug54478/ based on revid:mats.kindahl@stripped
3204 Olav Sandstaa 2010-09-08
Fix for Bug#54478 "mysqld crashes during boot when running mtr with --debug option"
The crash during boot was caused by a DBUG_PRINT statement in fill_schema_schemata() (in
sql_show.cc). This DBUG_PRINT statement contained several instances of %s in the format
string and for one of these we gave a NULL pointer as the argument. This caused the
call to vsnprintf() to crash when running on Solaris.
The fix for this problem is to ensure we do not give a NULL pointer as argument. If the
variable to be printed is NULL we instead give a "(null)" string as argument.
This patch also contains fixes for several other places where we gave a NULL pointer
as argument to %s fields in the format string for DBUG_PRINT. These caused several
individual tests to fail.
@ client/mysqltest.cc
Add a test for that string arguments to DBUG_PRINT() is not NULL pointers. If that
is the case we instead supply a string containing "(null)". This problem caused
vsnprintf() to crash on Solaris.
@ mysys/mf_format.c
Add a test for that string arguments to DBUG_PRINT() is not NULL pointers. If that
is the case we instead supply a string containing "(null)". This problem caused
vsnprintf() to crash on Solaris.
@ sql/field.cc
Add a test for that string arguments to DBUG_PRINT() is not NULL pointers. If that
is the case we instead supply a string containing "(null)". This problem caused
vsnprintf() to crash on Solaris.
@ sql/handler.cc
Add a test for that string arguments to DBUG_PRINT() is not NULL pointers. If that
is the case we instead supply a string containing "NULL". This problem caused
vsnprintf() to crash on Solaris.
@ sql/sql_class.cc
Add a test for that string arguments to DBUG_PRINT() is not NULL pointers. If that
is the case we instead supply a string containing "(null)". This problem caused
vsnprintf() to crash on Solaris.
@ sql/sql_db.cc
Add a test for that string arguments to DBUG_PRINT() is not NULL pointers. If that
is the case we instead supply a string containing "(null)". This problem caused
vsnprintf() to crash on Solaris.
@ sql/sql_insert.cc
Add a test for that string arguments to DBUG_PRINT() is not NULL pointers. If that
is the case we instead supply a string containing "(null)". This problem caused
vsnprintf() to crash on Solaris.
@ sql/sql_select.cc
Add a test for that string arguments to DBUG_PRINT() is not NULL pointers. If that
is the case we instead supply a string containing "(null)". This problem caused
vsnprintf() to crash on Solaris.
@ sql/sql_show.cc
Add a test for that string arguments to DBUG_PRINT() is not NULL pointers. If that
is the case we instead supply a string containing "(null)". This problem caused
vsnprintf() to crash on Solaris.
modified:
client/mysqltest.cc
mysys/mf_format.c
sql/field.cc
sql/handler.cc
sql/sql_class.cc
sql/sql_db.cc
sql/sql_insert.cc
sql/sql_select.cc
sql/sql_show.cc
=== modified file 'client/mysqltest.cc'
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc 2010-08-27 11:33:32 +0000
+++ b/client/mysqltest.cc 2010-09-08 08:37:18 +0000
@@ -2387,7 +2387,8 @@
{
DBUG_PRINT("info", ("At row %ld, column %d is '%s'",
- row_no, col_no, row[col_no]));
+ row_no, col_no,
+ row[col_no] ? row[col_no] : "(null)"));
/* Found the row to get */
if (row[col_no])
value= row[col_no];
=== modified file 'mysys/mf_format.c'
--- a/mysys/mf_format.c 2009-04-19 01:21:33 +0000
+++ b/mysys/mf_format.c 2010-09-08 08:37:18 +0000
@@ -32,7 +32,7 @@
size_t dev_length;
DBUG_ENTER("fn_format");
DBUG_PRINT("enter",("name: %s dir: %s extension: %s flag: %d",
- name,dir,extension,flag));
+ name, dir ? dir : "(null)", extension,flag));
/* Copy and skip directory */
name+=(length=dirname_part(dev, (startpos=(char *) name), &dev_length));
=== modified file 'sql/field.cc'
--- a/sql/field.cc 2010-08-23 09:56:21 +0000
+++ b/sql/field.cc 2010-09-08 08:37:18 +0000
@@ -6549,7 +6549,8 @@
{
uint length= min(field_length,max_length);
uint local_char_length= max_length/field_charset->mbmaxlen;
- DBUG_PRINT("debug", ("Packing field '%s' - length: %u ", field_name, length));
+ DBUG_PRINT("debug", ("Packing field '%s' - length: %u ",
+ field_name ? field_name : "(null)", length));
if (length > local_char_length)
local_char_length= my_charpos(field_charset, from, from+length,
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc 2010-08-09 18:33:47 +0000
+++ b/sql/handler.cc 2010-09-08 08:37:18 +0000
@@ -3877,7 +3877,8 @@
int error= 0;
DBUG_ENTER("ha_find_files");
DBUG_PRINT("enter", ("db: '%s' path: '%s' wild: '%s' dir: %d",
- db, path, wild ? wild : "NULL", dir));
+ db ? db : "NULL", path ? path : "NULL",
+ wild ? wild : "NULL", dir));
st_find_files_args args= {db, path, wild, dir, files};
plugin_foreach(thd, find_files_handlerton,
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2010-08-30 14:07:40 +0000
+++ b/sql/sql_class.cc 2010-09-08 08:37:18 +0000
@@ -3714,7 +3714,7 @@
int THD::decide_logging_format(TABLE_LIST *tables)
{
DBUG_ENTER("THD::decide_logging_format");
- DBUG_PRINT("info", ("query: %s", query()));
+ DBUG_PRINT("info", ("query: %s", query() ? query() : "(null)"));
DBUG_PRINT("info", ("variables.binlog_format: %lu",
variables.binlog_format));
DBUG_PRINT("info", ("lex->get_stmt_unsafe_flags(): 0x%x",
=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc 2010-07-19 08:27:53 +0000
+++ b/sql/sql_db.cc 2010-09-08 08:37:18 +0000
@@ -1438,7 +1438,8 @@
CHARSET_INFO *db_default_cl;
DBUG_ENTER("mysql_change_db");
- DBUG_PRINT("enter",("name: '%s'", new_db_name->str));
+ DBUG_PRINT("enter",
+ ("name: '%s'", new_db_name->str ? new_db_name->str : "(null)"));
if (new_db_name == NULL ||
new_db_name->length == 0)
=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc 2010-09-01 13:12:42 +0000
+++ b/sql/sql_insert.cc 2010-09-08 08:37:18 +0000
@@ -2348,7 +2348,8 @@
Delayed_insert *di=thd->di;
const Discrete_interval *forced_auto_inc;
DBUG_ENTER("write_delayed");
- DBUG_PRINT("enter", ("query = '%s' length %lu", query.str,
+ DBUG_PRINT("enter", ("query = '%s' length %lu",
+ query.str ? query.str : "(null)",
(ulong) query.length));
thd_proc_info(thd, "waiting for handler insert");
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2010-08-27 11:33:32 +0000
+++ b/sql/sql_select.cc 2010-09-08 08:37:18 +0000
@@ -11082,7 +11082,7 @@
MEM_ROOT own_root= entry->mem_root;
const char *save_proc_info;
DBUG_ENTER("free_tmp_table");
- DBUG_PRINT("enter",("table: %s",entry->alias));
+ DBUG_PRINT("enter",("table: %s", entry->alias ? entry->alias : "(null)"));
save_proc_info=thd->proc_info;
thd_proc_info(thd, "removing tmp table");
=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc 2010-08-30 14:07:40 +0000
+++ b/sql/sql_show.cc 2010-09-08 08:37:18 +0000
@@ -3719,8 +3719,10 @@
if (get_lookup_field_values(thd, cond, tables, &lookup_field_vals))
DBUG_RETURN(0);
DBUG_PRINT("INDEX VALUES",("db_name='%s', table_name='%s'",
- lookup_field_vals.db_value.str,
- lookup_field_vals.table_value.str));
+ lookup_field_vals.db_value.str ?
+ lookup_field_vals.db_value.str : "(null)",
+ lookup_field_vals.table_value.str ?
+ lookup_field_vals.table_value.str : "(null)"));
if (make_db_list(thd, &db_names, &lookup_field_vals,
&with_i_schema))
DBUG_RETURN(1);
Attachment: [text/bzr-bundle] bzr/olav@sun.com-20100908083718-6t8pwokjgw1gqf1i.bundle