summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2018-04-12 11:00:48 +0300
committerJan Lindström <jan.lindstrom@mariadb.com>2018-04-12 11:20:47 +0300
commit9c42b9038dc1457fd4aeed0520bc143a043a84d9 (patch)
tree0c55d8b0d8151bafd9297b746ff8d87fdf54f911
parent91245909a2f0c89444ecb5af587284f53b7196ee (diff)
downloadmariadb-git-9c42b9038dc1457fd4aeed0520bc143a043a84d9.tar.gz
MDEV-12632: Source and destination overlap in memcpy, encryption.innodb-discard-import-change fails in buildbot with valgrind
Problem was that if tablespace was encrypted we try to copy also page 0 from read buffer to write buffer that are in that case the same memory area. fil_iterate When tablespace is encrypted or compressed its first page (i.e. page 0) is not encrypted or compressed and there is no need to copy buffer.
-rw-r--r--storage/innobase/row/row0import.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index 1d2f5b3312e..2e8e709db37 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -3348,12 +3348,12 @@ fil_iterate(
bool updated = false;
os_offset_t page_off = offset;
ulint n_pages_read = n_bytes / size;
- bool decrypted = false;
block->page.id.set_page_no(ulint(page_off / size));
for (ulint i = 0; i < n_pages_read;
block->page.id.set_page_no(block->page.id.page_no() + 1),
++i, page_off += size, block->frame += size) {
+ bool decrypted = false;
err = DB_SUCCESS;
byte* src = readptr + i * size;
byte* dst = io_buffer + i * size;
@@ -3400,6 +3400,7 @@ fil_iterate(
block->frame = src;
frame_changed = true;
} else {
+ ut_ad(dst != src);
memcpy(dst, src, size);
}
}
@@ -3459,9 +3460,13 @@ page_corrupted:
ut_ad(encrypted ?
src != dst && dst != writeptr + (i * size):1);
- if (encrypted) {
- memcpy(writeptr + (i * size),
- callback.get_frame(block), size);
+ /* When tablespace is encrypted or compressed its
+ first page (i.e. page 0) is not encrypted or
+ compressed and there is no need to copy frame. */
+ if (encrypted && i != 0) {
+ byte *local_frame = callback.get_frame(block);
+ ut_ad((writeptr + (i * size)) != local_frame);
+ memcpy((writeptr + (i * size)), local_frame, size);
}
if (frame_changed) {
@@ -3499,6 +3504,7 @@ page_corrupted:
if (tmp == src) {
/* TODO: remove unnecessary memcpy's */
+ ut_ad(dest != src);
memcpy(dest, src, size);
}