Commit d2db80c8 authored by Sergey Glukhov's avatar Sergey Glukhov

Bug#38999 valgrind warnings for update statement in function compare_record()

Valgrind warning happpens because of uninitialized null bytes.
In row_sel_push_cache_row_for_mysql() function we fill fetch cache
with necessary field values, row_sel_store_mysql_rec() is called
for this and leaves null bytes untouched.
Later row_sel_pop_cached_row_for_mysql() rewrites table record
buffer with uninited null bytes. We can see the problem from the
test case:
At 'SELECT...' we call row_sel_push...->row_sel_store...->row_sel_pop_cached...
chain which rewrites table->record[0] buffer with uninitialized null bytes.
When we call 'UPDATE...' statement, compare_record uses this buffer and
valgrind warning occurs.
The fix is to init null bytes with default values.
parent d8aada88
......@@ -2378,4 +2378,16 @@ SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a;
SECOND(c)-@bug47453
0
DROP TABLE t1, t2;
#
# Bug#38999 valgrind warnings for update statement in function compare_record()
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 values (1),(2),(3),(4),(5);
INSERT INTO t2 values (1);
SELECT * FROM t1 WHERE a = 2;
a
2
UPDATE t1,t2 SET t1.a = t1.a + 100 WHERE t1.a = 1;
DROP TABLE t1,t2;
End of 5.1 tests
......@@ -618,5 +618,18 @@ SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a;
DROP TABLE t1, t2;
--echo #
--echo # Bug#38999 valgrind warnings for update statement in function compare_record()
--echo #
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 values (1),(2),(3),(4),(5);
INSERT INTO t2 values (1);
SELECT * FROM t1 WHERE a = 2;
UPDATE t1,t2 SET t1.a = t1.a + 100 WHERE t1.a = 1;
DROP TABLE t1,t2;
--echo End of 5.1 tests
......@@ -8,10 +8,6 @@
# NOTE: PLEASE SEE ps_1general.test (bottom)
# BEFORE ADDING NEW TEST CASES HERE !!!
# See Bug#38999 valgrind warnings for update statement in function
# compare_record()
-- source include/not_valgrind.inc
use test;
-- source include/have_innodb.inc
......
......@@ -2621,6 +2621,12 @@ row_sel_store_mysql_rec(
prebuilt->blob_heap = NULL;
}
/* init null bytes with default values as they might be
left uninitialized in some cases and this uninited bytes
might be copied into mysql record buffer that leads to
valgrind warnings */
memcpy(mysql_rec, prebuilt->default_rec, prebuilt->null_bitmap_len);
for (i = 0; i < prebuilt->n_template; i++) {
templ = prebuilt->mysql_template + i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment