diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2020-10-22 22:45:06 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2020-10-22 22:46:29 +0530 |
commit | b6fd3840640c29f851dbf8db2885e4e4fee9928d (patch) | |
tree | c273e86bcb6c7944142a1f47cf9c72295c4eb308 /mysys/mf_iocache.c | |
parent | 21ea14db8cc8c5d88ff804650de7caf984d08a98 (diff) | |
download | mariadb-git-10.2-mdev23867.tar.gz |
MDEV-23867: insert... select crash in compute_window_func10.2-mdev23867
There are 2 issues here:
Issue #1: memory allocation.
An IO_CACHE that uses encryption uses a larger buffer (it needs space for the encrypted data,
decrypted data, IO_CACHE_CRYPT struct to describe encryption parameters etc).
Issue #2: IO_CACHE::seek_not_done
When IO_CACHE objects are cloned, they still share the file descriptor.
This means, operation on one IO_CACHE may change the file read position
which will confuse other IO_CACHEs using it.
The fix of these issues would be:
Allocate the buffer to also include the extra size needed for encryption.
Perform seek again after one IO_CACHE reads a file.
Diffstat (limited to 'mysys/mf_iocache.c')
-rw-r--r-- | mysys/mf_iocache.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 5d74ba42677..e09c7f930c8 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -250,7 +250,7 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize, info->write_buffer= info->buffer + cachesize; else info->write_buffer= info->buffer; - info->alloced_buffer= 1; + info->alloced_buffer= buffer_block; break; /* Enough memory found */ } if (cachesize == min_cache) @@ -324,14 +324,14 @@ int init_slave_io_cache(IO_CACHE *master, IO_CACHE *slave) DBUG_ASSERT(!master->share); DBUG_ASSERT(master->alloced_buffer); - if (!(slave_buf= (uchar*)my_malloc(master->buffer_length, MYF(0)))) + if (!(slave_buf= (uchar*)my_malloc(master->alloced_buffer, MYF(0)))) { return 1; } memcpy(slave, master, sizeof(IO_CACHE)); slave->buffer= slave_buf; - memcpy(slave->buffer, master->buffer, master->buffer_length); + memcpy(slave->buffer, master->buffer, master->alloced_buffer); slave->read_pos= slave->buffer + (master->read_pos - master->buffer); slave->read_end= slave->buffer + (master->read_end - master->buffer); |