Fixes a race condition in function instantiation.
authorDerek Murray <mrry@google.com>
Sun, 11 Mar 2018 22:38:16 +0000 (15:38 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Sun, 11 Mar 2018 22:42:32 +0000 (15:42 -0700)
commit94e4ea20d9c1c780208d54d415cf3c318442ca18
tree0d5f6cdaae4c0fffe3b7588e5e494508e93733df
parentfcd8162a1ebb31b7e6847caa051652bc9217c9ad
Fixes a race condition in function instantiation.

Previously, if the same function was being concurrently instantiated
and released:

1. Thread one could begin to instantiate the function, determine
   that it already existed in the runtime, then be preempted.
2. Thread two could release the handle on the function, causing it to
   be freed and removed from the `FunctionLibraryRuntime::items_` map.
3. Thread one could then incorrectly assume that the function still
   existed, and fail to find it in the `FunctionLibraryRuntime::items_`
   map, causing a segfault when it attempted to increment the refcount
   on an uninitialized object.

PiperOrigin-RevId: 188661500
tensorflow/core/common_runtime/function.cc
tensorflow/python/data/kernel_tests/filter_dataset_op_test.py