diff --git a/src/Microsoft.ML.FastTree/TreeEnsembleFeaturizer.cs b/src/Microsoft.ML.FastTree/TreeEnsembleFeaturizer.cs index 8d6ff695fb..2d2977fbe6 100644 --- a/src/Microsoft.ML.FastTree/TreeEnsembleFeaturizer.cs +++ b/src/Microsoft.ML.FastTree/TreeEnsembleFeaturizer.cs @@ -735,7 +735,6 @@ private static IDataView AppendFloatMapper(IHostEnvironment env, IChanne bool identity; var converter = Conversions.Instance.GetStandardConversion(type, dstType, out identity); var isNa = Conversions.Instance.GetIsNAPredicate(type); - ulong temp = 0; ValueMapper mapper; if (seed == 0) @@ -743,6 +742,10 @@ private static IDataView AppendFloatMapper(IHostEnvironment env, IChanne mapper = (in TInput src, ref Single dst) => { + //Attention: This method is called from multiple threads. + //Do not move the temp variable outside this method. + //If you do, the variable is shared between the threads and results in a race condition. + ulong temp = 0; if (isNa(in src)) { dst = Single.NaN; @@ -759,6 +762,10 @@ private static IDataView AppendFloatMapper(IHostEnvironment env, IChanne mapper = (in TInput src, ref Single dst) => { + //Attention: This method is called from multiple threads. + //Do not move the temp variable outside this method. + //If you do, the variable is shared between the threads and results in a race condition. + ulong temp = 0; if (isNa(in src)) { dst = Single.NaN;