message: Fixes a race condition in TensorForest tree traversal code resulting in use-after-free of input dense/sparse tensors.
  The race occurs when multiple TreePredictionsV4Op kernels are invoked simultaneously resulting in data_set_.set_input_tensors() being invoked concurrently with tree traversal code accessing the current tensors.
diff: @@ -169,10 +169,6 @@ class TreePredictionsV4Op : public OpKernel {
  string serialized_proto;
  OP_REQUIRES_OK(context, context->GetAttr("input_spec", &serialized_proto));
  input_spec_.ParseFromString(serialized_proto);
  -
  - data_set_ =
  - std::unique_ptr<TensorDataSet>(new TensorDataSet(input_spec_, 0));
  -
  model_op_ = LeafModelOperatorFactory::CreateLeafModelOperator(param_proto_);
  }
  @@ -182,7 +178,8 @@ class TreePredictionsV4Op : public OpKernel {
  const Tensor& sparse_input_values = context->input(3);
  const Tensor& sparse_input_shape = context->input(4);
  - data_set_->set_input_tensors(input_data, sparse_input_indices,
  + std::unique_ptr<TensorDataSet> data_set(new TensorDataSet(input_spec_, 0));
  + data_set->set_input_tensors(input_data, sparse_input_indices,
  sparse_input_values, sparse_input_shape);
  DecisionTreeResource* decision_tree_resource;
  @@ -191,7 +188,7 @@ class TreePredictionsV4Op : public OpKernel {
  mutex_lock l(*decision_tree_resource->get_mutex());
  core::ScopedUnref unref_me(decision_tree_resource);
  - const int num_data = data_set_->NumItems();
  + const int num_data = data_set->NumItems();
  const int32 num_outputs = param_proto_.num_outputs();
  Tensor* output_predictions = nullptr;
  @@ -208,11 +205,11 @@ class TreePredictionsV4Op : public OpKernel {
  auto worker_threads = context->device()->tensorflow_cpu_worker_threads();
  int num_threads = worker_threads->num_threads;
  const int64 costPerTraverse = 500;
  - auto traverse = [this, &out, decision_tree_resource, num_data, &tree_paths](
  - int64 start, int64 end) {
  + auto traverse = [this, &out, &data_set, decision_tree_resource, num_data,
  + &tree_paths](int64 start, int64 end) {
  CHECK(start <= end);
  CHECK(end <= num_data);
  - TraverseTree(decision_tree_resource, data_set_, static_cast<int32>(start),
  + TraverseTree(decision_tree_resource, data_set, static_cast<int32>(start),
  static_cast<int32>(end),
  std::bind(&TreePredictionsV4Op::set_output_value, this,
  std::placeholders::_1, std::placeholders::_2,
  @@ -259,7 +256,6 @@ class TreePredictionsV4Op : public OpKernel {
  private:
  tensorforest::TensorForestDataSpec input_spec_;
  - std::unique_ptr<TensorDataSet> data_set_;
  std::unique_ptr<LeafModelOperator> model_op_;
  TensorForestParams param_proto_;
  };
  