3206 Olav Sandstaa 2010-09-15
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 replace the call to vsnprintf() with my_vsnprintf()
which handles that a NULL pointer is passed as argumens for %s.
This patch also extends my_vsnprintf() to support %i in the format string.
@ dbug/dbug.c
Replace the use of vsnprintf() with my_vsnprintf(). On some platforms
vsnprintf() did not handle that a NULL pointer was given as an argument
for a %s in the format string.
@ include/mysql/service_my_snprintf.h
Add support for %i in format string to my_vsnprintf().
@ strings/my_vsnprintf.c
Add support for %i in format string to my_vsnprintf().
@ unittest/mysys/my_vsnprintf-t.c
Add unit tests for %i in format string to my_vsnprintf().
modified:
dbug/dbug.c
include/mysql/service_my_snprintf.h
strings/my_vsnprintf.c
unittest/mysys/my_vsnprintf-t.c
3205 Marc Alff 2010-09-14 [merge]
Local merge
modified:
client/mysqltest.cc
libmysqld/lib_sql.cc
mysql-test/include/default_mysqld.cnf
mysql-test/r/func_time.result
mysql-test/r/parser.result
mysql-test/r/select.result
mysql-test/r/strict.result
mysql-test/r/type_datetime.result
mysql-test/suite/perfschema/include/upgrade_check.inc
mysql-test/suite/perfschema/r/start_server_no_cond_class.result
mysql-test/suite/perfschema/r/start_server_no_cond_inst.result
mysql-test/suite/perfschema/r/start_server_no_file_class.result
mysql-test/suite/perfschema/r/start_server_no_file_inst.result
mysql-test/suite/perfschema/r/start_server_no_mutex_class.result
mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result
mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result
mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result
mysql-test/suite/perfschema/r/start_server_no_thread_class.result
mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
mysql-test/suite/perfschema/r/start_server_off.result
mysql-test/suite/perfschema/r/start_server_on.result
mysql-test/t/strict.test
mysql-test/t/type_datetime.test
mysys/my_gethwaddr.c
mysys/my_sync.c
sql/derror.cc
sql/item_timefunc.cc
sql/item_timefunc.h
sql/mysqld.cc
sql/set_var.cc
sql/set_var.h
sql/sys_vars.h
storage/perfschema/ha_perfschema.cc
=== modified file 'dbug/dbug.c'
=== modified file 'dbug/dbug.c'
--- a/dbug/dbug.c 2010-07-15 11:16:06 +0000
+++ b/dbug/dbug.c 2010-09-15 11:33:22 +0000
@@ -1335,15 +1335,11 @@
* This function is intended as a
* vfprintf clone with consistent, platform independent output for
* problematic formats like %p, %zd and %lld.
- * However: full functionality for my_vsnprintf has not been backported yet,
- * so code using "%g" or "%f" will have undefined behaviour.
*/
static void DbugVfprintf(FILE *stream, const char* format, va_list args)
{
char cvtbuf[1024];
- size_t len;
- /* Do not use my_vsnprintf, it does not support "%g". */
- len = vsnprintf(cvtbuf, sizeof(cvtbuf), format, args);
+ (void) my_vsnprintf(cvtbuf, sizeof(cvtbuf), format, args);
(void) fprintf(stream, "%s\n", cvtbuf);
}
=== modified file 'include/mysql/service_my_snprintf.h'
--- a/include/mysql/service_my_snprintf.h 2010-07-20 19:34:20 +0000
+++ b/include/mysql/service_my_snprintf.h 2010-09-15 11:33:22 +0000
@@ -53,7 +53,7 @@
<length modifier> can be 'l', 'll', or 'z'.
Supported formats are 's' (null pointer is accepted, printed as
- "(null)"), 'b' (extension, see below), 'c', 'd', 'u', 'x', 'o',
+ "(null)"), 'b' (extension, see below), 'c', 'd', 'i', 'u', 'x', 'o',
'X', 'p' (works as 0x%x).
Standard syntax for positional arguments $n is supported.
=== modified file 'strings/my_vsnprintf.c'
--- a/strings/my_vsnprintf.c 2009-12-28 12:54:16 +0000
+++ b/strings/my_vsnprintf.c 2010-09-15 11:33:22 +0000
@@ -255,7 +255,7 @@
if ((to_length= (size_t) (end-to)) < 16 || length)
store_start= buff;
- if (arg_type == 'd')
+ if (arg_type == 'd' || arg_type == 'i')
store_end= longlong10_to_str(par, store_start, -10);
else if (arg_type == 'u')
store_end= longlong10_to_str(par, store_start, 10);
@@ -399,6 +399,7 @@
args_arr[i].double_arg= va_arg(ap, double);
break;
case 'd':
+ case 'i':
case 'u':
case 'x':
case 'X':
@@ -406,7 +407,7 @@
case 'p':
if (args_arr[i].have_longlong)
args_arr[i].longlong_arg= va_arg(ap,longlong);
- else if (args_arr[i].arg_type == 'd')
+ else if (args_arr[i].arg_type == 'd' || args_arr[i].arg_type == 'i')
args_arr[i].longlong_arg= va_arg(ap, int);
else
args_arr[i].longlong_arg= va_arg(ap, uint);
@@ -458,6 +459,7 @@
break;
}
case 'd':
+ case 'i':
case 'u':
case 'x':
case 'X':
@@ -472,7 +474,7 @@
if (args_arr[print_arr[i].arg_idx].have_longlong)
larg = args_arr[print_arr[i].arg_idx].longlong_arg;
- else if (print_arr[i].arg_type == 'd')
+ else if (print_arr[i].arg_type == 'd' || print_arr[i].arg_type == 'i' )
larg = (int) args_arr[print_arr[i].arg_idx].longlong_arg;
else
larg= (uint) args_arr[print_arr[i].arg_idx].longlong_arg;
@@ -615,8 +617,8 @@
to= process_dbl_arg(to, end, width, d, *fmt);
continue;
}
- else if (*fmt == 'd' || *fmt == 'u' || *fmt == 'x' || *fmt == 'X' ||
- *fmt == 'p' || *fmt == 'o')
+ else if (*fmt == 'd' || *fmt == 'i' || *fmt == 'u' || *fmt == 'x' ||
+ *fmt == 'X' || *fmt == 'p' || *fmt == 'o')
{
/* Integer parameter */
longlong larg;
@@ -625,7 +627,7 @@
if (have_longlong)
larg = va_arg(ap,longlong);
- else if (*fmt == 'd')
+ else if (*fmt == 'd' || *fmt == 'i')
larg = va_arg(ap, int);
else
larg= va_arg(ap, uint);
=== modified file 'unittest/mysys/my_vsnprintf-t.c'
--- a/unittest/mysys/my_vsnprintf-t.c 2009-12-28 12:54:16 +0000
+++ b/unittest/mysys/my_vsnprintf-t.c 2010-09-15 11:33:22 +0000
@@ -31,7 +31,7 @@
int main(void)
{
- plan(54);
+ plan(58);
test1("Constant string",
"Constant string");
@@ -44,6 +44,8 @@
"Format specifier c %c", '!');
test1("Format specifier d 1",
"Format specifier d %d", 1);
+ test1("Format specifier i 1",
+ "Format specifier i %i", 1);
test1("Format specifier u 2",
"Format specifier u %u", 2);
test1("Format specifier o 375",
@@ -77,6 +79,9 @@
test1("Length modifiers work: 1 * -1 * 2 * 3",
"Length modifiers work: %d * %ld * %lld * %zd", 1, -1L, 2LL, (size_t)3);
+ test1("Length modifiers work: 1 * -1 * 2 * 3",
+ "Length modifiers work: %i * %li * %lli * %zd", 1, -1L, 2LL, (size_t)3);
+
test1("long long X: 123456789abcdef0",
"long long X: %llx", 0x123456789abcdef0LL);
@@ -121,6 +126,10 @@
"Hello int, %d", 1);
test1("Hello int, -1",
"Hello int, %d", -1);
+ test1("Hello int, 1",
+ "Hello int, %i", 1);
+ test1("Hello int, -1",
+ "Hello int, %i", -1);
test1("Hello string 'I am a string'",
"Hello string '%s'", "I am a string");
test1("Hello hack hack hack hack hack hack hack 1",
Attachment: [text/bzr-bundle] bzr/olav.sandstaa@oracle.com-20100915113322-io8n04jkw0o7dack.bundle
| Thread |
|---|
| • bzr push into mysql-5.5-bugfixing branch (olav.sandstaa:3205 to 3206)Bug#54478 | Olav Sandstaa | 15 Sep |