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(-) (limited to 'dbug') 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 From 37c88445e30d52c965bcb19b19fa710c3eb4fad9 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 31 Mar 2020 07:57:53 +1100 Subject: mtr: use env for perl On FreeBSD, perl isn't in /usr/bin, its in /usr/local/bin or elsewhere in the path. Like storage/{maria/unittest/,}ma_test_* , we use /usr/bin/env to find perl and run it. --- dbug/dbug_add_tags.pl | 2 +- dbug/remove_function_from_trace.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'dbug') diff --git a/dbug/dbug_add_tags.pl b/dbug/dbug_add_tags.pl index 7be8fb9b18d..f117bdcd65b 100755 --- a/dbug/dbug_add_tags.pl +++ b/dbug/dbug_add_tags.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Copyright (c) 2002 MySQL AB, 2009 Sun Microsystems, Inc. # Use is subject to license terms. diff --git a/dbug/remove_function_from_trace.pl b/dbug/remove_function_from_trace.pl index 380df168caf..67d7fa54b6a 100755 --- a/dbug/remove_function_from_trace.pl +++ b/dbug/remove_function_from_trace.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl die < Date: Thu, 25 Jun 2020 09:58:42 +0200 Subject: MDEV-22950 followup Deadlock in DbugParse, on Linux. In 10.1, DBUG recursive mutex was improperly implemented. CODE_STATE::locked counter was never updated. Copy the code around LockMutex/UnlockMutex from 10.2 --- dbug/dbug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'dbug') diff --git a/dbug/dbug.c b/dbug/dbug.c index b0e1b0eaae6..007769c3c37 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -330,10 +330,13 @@ static void LockMutex(CODE_STATE *cs) { if (!cs->locked) pthread_mutex_lock(&THR_LOCK_dbug); + cs->locked++; } static void UnlockMutex(CODE_STATE *cs) { - if (!cs->locked) + --cs->locked; + assert(cs->locked >= 0); + if (cs->locked == 0) pthread_mutex_unlock(&THR_LOCK_dbug); } static void LockIfInitSettings(CODE_STATE *cs) -- cgit v1.2.1