[tf.data] Fix use-after-free bug when closing down an input pipeline.
authorDerek Murray <mrry@google.com>
Mon, 5 Feb 2018 21:43:52 +0000 (13:43 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Mon, 5 Feb 2018 21:51:04 +0000 (13:51 -0800)
commit1bbfc0c9cebd1808fa46024f738e56d10d57d97e
tree3119be9aac04b1d74696c82ac7dbaffdd1b9b997
parentb3360e040602a2aa46fb9e27c7af940d651a704b
[tf.data] Fix use-after-free bug when closing down an input pipeline.

This fix affects the distributed runtime; DirectSession use is unaffected.

Before this change, an iterator that used a background prefetching
thread might attempt to use a captured FunctionLibraryRuntime from a
subgraph that had been deregistered (and hence its
FunctionLibraryRuntime would have been deleted). This change
introduces a mechanism for "cloning" the necessary parts of the
FunctionLibraryRuntime so that it can be owned by the
IteratorResource.

PiperOrigin-RevId: 184579490
tensorflow/core/common_runtime/function.cc
tensorflow/core/common_runtime/graph_optimizer.h
tensorflow/core/common_runtime/process_function_library_runtime.cc
tensorflow/core/common_runtime/process_function_library_runtime.h
tensorflow/core/framework/function.h
tensorflow/core/kernels/data/iterator_ops.cc
tensorflow/python/data/kernel_tests/iterator_ops_cluster_test.py