From ded07724eebb6c3afe882884fbad32e8dc907b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Mon, 29 Jan 2018 19:46:59 +0200 Subject: [PATCH 1/3] MDEV-15014 Assertion `m_cache_lock_status == LOCKED_NO_WAIT || m_cache_status == DISABLE_REQUEST' failed in Query_cache::free_cache on startup The assert guards against not-locked or not-requested query cache disabling. If during startup we disable query cache, we failed to request disabling. --- sql/sql_cache.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 3fc1edfcb56..6effc376a2f 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -2477,6 +2477,7 @@ void Query_cache::init() */ if (global_system_variables.query_cache_type == 0) { + m_cache_status= DISABLE_REQUEST; free_cache(); m_cache_status= DISABLED; } From 5edd129fbf14eb56e793f84963b3b9e5770c4604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 30 Jan 2018 21:05:27 +0200 Subject: [PATCH 2/3] Fix ASAN failure in main.lock (and others) Whenever one copies an IO_CACHE struct, one must remember to call setup_io_cache, if not, the IO_CACHE's current_pos and end_pos self-references will point to the previous struct's memory, which could go out of scope. Commit 90038693903044bbbf7946ac128c3757ad33d7ba fixes this problem in a more general fashion by removing the self-references altogether, but for 5.5 we'll keep the old behaviour. --- sql/sql_update.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index ede38468513..e42f6a4ff76 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -628,6 +628,8 @@ int mysql_update(THD *thd, if (reinit_io_cache(&tempfile,READ_CACHE,0L,0,0)) error=1; /* purecov: inspected */ select->file=tempfile; // Read row ptrs from this file + // select->file was copied, update self-references. + setup_io_cache(&select->file); if (error >= 0) goto err; } From 7a63ffab71644118223aefe66094366a7b7f115e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Mon, 29 Jan 2018 18:56:08 +0200 Subject: [PATCH 3/3] Fix an out of scope bzero --- mysys/mf_iocache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 31a09e214d2..bd71e2ae527 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -258,7 +258,7 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize, else { /* Clear mutex so that safe_mutex will notice that it's not initialized */ - bzero((char*) &info->append_buffer_lock, sizeof(info)); + bzero((char*) &info->append_buffer_lock, sizeof(info->append_buffer_lock)); } #endif