List:Commits« Previous MessageNext Message »
From:Jorgen Loland Date:November 4 2011 3:23pm
Subject:bzr push into mysql-trunk branch (jorgen.loland:3562 to 3564) Bug#12997905
View as plain text  
 3564 Jorgen Loland	2011-11-04
      BUG#12997905 Followup patch
      
      Hopefully PB stops barking about two VALGRIND errors after push
      of this bug.
     @ mysql-test/valgrind.supp
        Removed two valgrind supression patterns.

    modified:
      mysql-test/valgrind.supp
 3563 Jorgen Loland	2011-11-04
      Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) 
                    POINTS TO UNINITIALISED BYTE(S)
      
      When a record is inserted into a MyISAM temporary table using 
      static write, the entire content of the record[0] buffer is 
      written to the table which resides on disk. If one or more of
      the columns is a varchar, the trailing space may be 
      uninitialized and even contain secrets. Valgrind barked because
      of this.
      
      The fix is to reset the record buffer for MyISAM temporary 
      tables in addition to restricting the copying of fields from
      one table to another to the bytes actually used by the varchar.
      
      Bonus: Restricting Copy_field to copy only used varchar bytes 
      instead of the full column length also has a performance 
      benefit.
     @ mysql-test/include/join_cache.inc
        Add test case for BUG#12997905
     @ mysql-test/r/join_cache_bka.result
        Add test case for BUG#12997905
     @ mysql-test/r/join_cache_bka_nixbnl.result
        Add test case for BUG#12997905
     @ mysql-test/r/join_cache_bkaunique.result
        Add test case for BUG#12997905
     @ mysql-test/r/join_cache_bnl.result
        Add test case for BUG#12997905
     @ mysql-test/r/join_cache_nojb.result
        Add test case for BUG#12997905
     @ sql/field.h
        Document Copy_field length variables
     @ sql/field_conv.cc
        Copy_field now only copies actual characters for varchar columns. 
        Before, the trailing space was also copied.
     @ sql/sql_select.cc
        Reset record buffer for MyISAM temporary tables to avoid writing
        the random content in the alloced memory to file

    modified:
      mysql-test/include/join_cache.inc
      mysql-test/r/join_cache_bka.result
      mysql-test/r/join_cache_bka_nixbnl.result
      mysql-test/r/join_cache_bkaunique.result
      mysql-test/r/join_cache_bnl.result
      mysql-test/r/join_cache_nojb.result
      sql/field.h
      sql/field_conv.cc
      sql/sql_select.cc
 3562 Jon Olav Hauglid	2011-11-04
      Fix trunk tree_name.

    modified:
      .bzr-mysql/default.conf
=== modified file 'mysql-test/include/join_cache.inc'
--- a/mysql-test/include/join_cache.inc	2011-08-08 14:16:20 +0000
+++ b/mysql-test/include/join_cache.inc	2011-11-04 15:20:13 +0000
@@ -1961,3 +1961,26 @@ eval EXPLAIN $query;
 eval $query;
 
 DROP TABLE t1, t2, t3, t4;
+
+--echo #
+--echo # Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) 
+--echo #               POINTS TO UNINITIALISED BYTE(S)
+--echo #
+
+CREATE TABLE t1 (
+  col1 varchar(10),
+  col2 varchar(1024)
+) ENGINE=innodb;
+
+INSERT INTO t1 VALUES ('a','a');
+
+CREATE TABLE t2 (i varchar(10)) ENGINE=innodb;
+INSERT INTO t2 VALUES ('a');
+
+SELECT t1.col1
+FROM t1 JOIN t2 ON t1.col1 = t2.i 
+GROUP BY t1.col2;
+
+DROP TABLE t1,t2;
+
+--echo # End of Bug#12997905

=== modified file 'mysql-test/r/join_cache_bka.result'
--- a/mysql-test/r/join_cache_bka.result	2011-10-27 08:52:27 +0000
+++ b/mysql-test/r/join_cache_bka.result	2011-11-04 15:20:13 +0000
@@ -2681,4 +2681,22 @@ col_int
 NULL
 NULL
 DROP TABLE t1, t2, t3, t4;
+#
+# Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) 
+#               POINTS TO UNINITIALISED BYTE(S)
+#
+CREATE TABLE t1 (
+col1 varchar(10),
+col2 varchar(1024)
+) ENGINE=innodb;
+INSERT INTO t1 VALUES ('a','a');
+CREATE TABLE t2 (i varchar(10)) ENGINE=innodb;
+INSERT INTO t2 VALUES ('a');
+SELECT t1.col1
+FROM t1 JOIN t2 ON t1.col1 = t2.i 
+GROUP BY t1.col2;
+col1
+a
+DROP TABLE t1,t2;
+# End of Bug#12997905
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_bka_nixbnl.result'
--- a/mysql-test/r/join_cache_bka_nixbnl.result	2011-10-27 08:52:27 +0000
+++ b/mysql-test/r/join_cache_bka_nixbnl.result	2011-11-04 15:20:13 +0000
@@ -2681,4 +2681,22 @@ col_int
 NULL
 NULL
 DROP TABLE t1, t2, t3, t4;
+#
+# Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) 
+#               POINTS TO UNINITIALISED BYTE(S)
+#
+CREATE TABLE t1 (
+col1 varchar(10),
+col2 varchar(1024)
+) ENGINE=innodb;
+INSERT INTO t1 VALUES ('a','a');
+CREATE TABLE t2 (i varchar(10)) ENGINE=innodb;
+INSERT INTO t2 VALUES ('a');
+SELECT t1.col1
+FROM t1 JOIN t2 ON t1.col1 = t2.i 
+GROUP BY t1.col2;
+col1
+a
+DROP TABLE t1,t2;
+# End of Bug#12997905
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_bkaunique.result'
--- a/mysql-test/r/join_cache_bkaunique.result	2011-10-27 08:52:27 +0000
+++ b/mysql-test/r/join_cache_bkaunique.result	2011-11-04 15:20:13 +0000
@@ -2682,4 +2682,22 @@ col_int
 NULL
 NULL
 DROP TABLE t1, t2, t3, t4;
+#
+# Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) 
+#               POINTS TO UNINITIALISED BYTE(S)
+#
+CREATE TABLE t1 (
+col1 varchar(10),
+col2 varchar(1024)
+) ENGINE=innodb;
+INSERT INTO t1 VALUES ('a','a');
+CREATE TABLE t2 (i varchar(10)) ENGINE=innodb;
+INSERT INTO t2 VALUES ('a');
+SELECT t1.col1
+FROM t1 JOIN t2 ON t1.col1 = t2.i 
+GROUP BY t1.col2;
+col1
+a
+DROP TABLE t1,t2;
+# End of Bug#12997905
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_bnl.result'
--- a/mysql-test/r/join_cache_bnl.result	2011-10-27 08:52:27 +0000
+++ b/mysql-test/r/join_cache_bnl.result	2011-11-04 15:20:13 +0000
@@ -2682,4 +2682,22 @@ col_int
 NULL
 NULL
 DROP TABLE t1, t2, t3, t4;
+#
+# Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) 
+#               POINTS TO UNINITIALISED BYTE(S)
+#
+CREATE TABLE t1 (
+col1 varchar(10),
+col2 varchar(1024)
+) ENGINE=innodb;
+INSERT INTO t1 VALUES ('a','a');
+CREATE TABLE t2 (i varchar(10)) ENGINE=innodb;
+INSERT INTO t2 VALUES ('a');
+SELECT t1.col1
+FROM t1 JOIN t2 ON t1.col1 = t2.i 
+GROUP BY t1.col2;
+col1
+a
+DROP TABLE t1,t2;
+# End of Bug#12997905
 set optimizer_switch = default;

=== modified file 'mysql-test/r/join_cache_nojb.result'
--- a/mysql-test/r/join_cache_nojb.result	2011-10-27 08:52:27 +0000
+++ b/mysql-test/r/join_cache_nojb.result	2011-11-04 15:20:13 +0000
@@ -2682,4 +2682,22 @@ NULL
 3
 NULL
 DROP TABLE t1, t2, t3, t4;
+#
+# Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) 
+#               POINTS TO UNINITIALISED BYTE(S)
+#
+CREATE TABLE t1 (
+col1 varchar(10),
+col2 varchar(1024)
+) ENGINE=innodb;
+INSERT INTO t1 VALUES ('a','a');
+CREATE TABLE t2 (i varchar(10)) ENGINE=innodb;
+INSERT INTO t2 VALUES ('a');
+SELECT t1.col1
+FROM t1 JOIN t2 ON t1.col1 = t2.i 
+GROUP BY t1.col2;
+col1
+a
+DROP TABLE t1,t2;
+# End of Bug#12997905
 set optimizer_switch = default;

=== modified file 'mysql-test/valgrind.supp'
--- a/mysql-test/valgrind.supp	2011-10-07 06:03:14 +0000
+++ b/mysql-test/valgrind.supp	2011-11-04 15:22:50 +0000
@@ -1023,35 +1023,3 @@
    fun:_Z*10write_keysP10Sort_paramPPhjP11st_io_cacheS4_
    fun:_Z8filesortP3THDP5TABLEP13st_sort_fieldjP10SQL_SELECTybPyS7_
 }
-
-# Syscall param write(buf) points to uninitialised byte(s)
-# The '...' wildcard is for 'fun:inline_mysql_file_write' which *may*
-# be inlined.
-{
-   Bug#12879084 VALGRIND FAILURE IN INNODB.INNODB_BUFFER_POOL_LOAD / one
-   Memcheck:Param
-   write(buf)
-   obj:*/libpthread*.so
-   fun:my_write
-   ...
-   fun:my_b_flush_io_cache
-   fun:end_io_cache
-   fun:mi_extra
-   fun:_ZN9ha_myisam5extraE17ha_extra_function
-}
-
-{
-   Bug#12879084 VALGRIND FAILURE IN INNODB.INNODB_BUFFER_POOL_LOAD / two
-   Memcheck:Param
-   write(buf)
-   obj:*/libpthread*.so
-   fun:my_write
-   fun:my_b_flush_io_cache
-   fun:_my_b_write
-   fun:_mi_write_part_record
-   fun:write_dynamic_record
-   fun:_mi_write_blob_record
-   fun:mi_write
-   fun:_ZN9ha_myisam9write_rowEPh
-   fun:_ZN7handler12ha_write_rowEPh
-}

=== modified file 'sql/field.h'
--- a/sql/field.h	2011-10-11 04:27:52 +0000
+++ b/sql/field.h	2011-11-04 15:20:13 +0000
@@ -2454,6 +2454,23 @@ public:
   uchar *from_null_ptr,*to_null_ptr;
   my_bool *null_row;
   uint	from_bit,to_bit;
+  /**
+    Number of bytes in the fields pointed to by 'from_ptr' and
+    'to_ptr'. Usually this is the number of bytes that are copied from
+    'from_ptr' to 'to_ptr'.
+
+    For variable-length fields (VARCHAR), the first byte(s) describe
+    the actual length of the text. For VARCHARs with length 
+       < 256 there is 1 length byte 
+       >= 256 there is 2 length bytes
+    Thus, if from_field is VARCHAR(10), from_length (and in most cases
+    to_length) is 11. For VARCHAR(1024), the length is 1026. @see
+    Field_varstring::length_bytes
+
+    Note that for VARCHARs, do_copy() will be do_varstring*() which
+    only copies the length-bytes (1 or 2) + the actual length of the
+    text instead of from/to_length bytes. @see get_copy_func()
+  */
   uint from_length,to_length;
   Field *from_field,*to_field;
   String tmp;					// For items

=== modified file 'sql/field_conv.cc'
--- a/sql/field_conv.cc	2011-07-28 10:54:44 +0000
+++ b/sql/field_conv.cc	2011-11-04 15:20:13 +0000
@@ -709,7 +709,7 @@ Copy_field::get_copy_func(Field *to,Fiel
         if (((Field_varstring*) to)->length_bytes !=
             ((Field_varstring*) from)->length_bytes)
           return do_field_string;
-        if (to_length != from_length)
+        else
           return (((Field_varstring*) to)->length_bytes == 1 ?
                   (from->charset()->mbmaxlen == 1 ? do_varstring1 :
                                                     do_varstring1_mb) :

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-11-03 16:03:34 +0000
+++ b/sql/sql_select.cc	2011-11-04 15:20:13 +0000
@@ -18468,6 +18468,8 @@ bool instantiate_tmp_table(TABLE *table,
     if (create_myisam_tmp_table(table, keyinfo, start_recinfo, recinfo,
                                 options, big_tables))
       return TRUE;
+    // Make empty record so random data is not written to disk
+    empty_record(table);
   }
   if (open_tmp_table(table))
     return TRUE;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (jorgen.loland:3562 to 3564) Bug#12997905Jorgen Loland7 Nov