From 727252ff1bb65c7abddc5a9acb17304695c09265 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 20 Jun 2020 01:00:36 +0200 Subject: MDEV-22950 : fix race condition in dbug FreeState() zeros init_settings.out_file, which another thread can be using --- dbug/dbug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbug/dbug.c b/dbug/dbug.c index 21f86ded0a5..b0e1b0eaae6 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -483,6 +483,7 @@ static int DbugParse(CODE_STATE *cs, const char *control) rel= control[0] == '+' || control[0] == '-'; if ((!rel || (!stack->out_file && !stack->next))) { + LockIfInitSettings(cs); FreeState(cs, 0); stack->flags= 0; stack->delay= 0; @@ -490,10 +491,9 @@ static int DbugParse(CODE_STATE *cs, const char *control) stack->sub_level= 0; stack->out_file= sstderr; stack->functions= NULL; - LockIfInitSettings(cs); stack->keywords= NULL; - UnlockIfInitSettings(cs); stack->processes= NULL; + UnlockIfInitSettings(cs); } else if (!stack->out_file) { -- cgit v1.2.1