From b734cd73ffb0c47da7155b3ac6869a64a15337a3 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 11 Dec 2013 11:15:23 +0100 Subject: [PATCH] Bug#17928281 'CHECK_PERFORMANCE_SCHEMA()' LEAVES 'CURRENT_THD' REFERRING DESTRUCTED THD OBJ Prior to fix, function check_performance_schema() could leave behind stale pointers in thread local storage, for the following keys: - THR_THD (used by _current_thd) - THR_MALLOC (used for memory allocation) This is an unsafe practice, which can potentially cause crashes, and that can cause other bugs when code is modified during maintenance. With this fix, thread local storage keys used temporarily within function check_performance_schema() are cleaned up after use. --- storage/perfschema/pfs_check.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/perfschema/pfs_check.cc b/storage/perfschema/pfs_check.cc index c52be6f0da2..97b23c38065 100644 --- a/storage/perfschema/pfs_check.cc +++ b/storage/perfschema/pfs_check.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -55,6 +55,7 @@ void check_performance_schema() PFS_engine_table_share::check_all_tables(thd); + thd->restore_globals(); delete thd; DBUG_VOID_RETURN; }