From b908680bec6981ff7d9c394ec625671400c7ce6c Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Fri, 21 Apr 2023 05:24:10 +0800 Subject: [PATCH] Fix race condition in cpp metric tests. (#9058) --- src/metric/elementwise_metric.cu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/metric/elementwise_metric.cu b/src/metric/elementwise_metric.cu index b1c76404715a..01aec16e10c8 100644 --- a/src/metric/elementwise_metric.cu +++ b/src/metric/elementwise_metric.cu @@ -217,7 +217,7 @@ struct EvalError { } } const char *Name() const { - static std::string name; + static thread_local std::string name; if (has_param_) { std::ostringstream os; os << "error"; @@ -315,7 +315,7 @@ struct EvalTweedieNLogLik { << "tweedie variance power must be in interval [1, 2)"; } const char *Name() const { - static std::string name; + static thread_local std::string name; std::ostringstream os; os << "tweedie-nloglik@" << rho_; name = os.str();