aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/lib
diff options
context:
space:
mode:
authorGravatar Derek Murray <mrry@google.com>2018-08-02 11:07:52 -0700
committerGravatar GitHub <noreply@github.com>2018-08-02 11:07:52 -0700
commitfbd62e568b65a6f5dedeea173d23dd2b28828e43 (patch)
tree3226d44e20199146ebb2740eda866934bebb5269 /tensorflow/python/lib
parent8cd2d6fe9389e93a4182ae9287f2f8325913fe6c (diff)
Add a defensive comment about the TOCTOU race
Diffstat (limited to 'tensorflow/python/lib')
-rw-r--r--tensorflow/python/lib/core/py_func.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/tensorflow/python/lib/core/py_func.cc b/tensorflow/python/lib/core/py_func.cc
index 8c1fa31f05..a3c541da87 100644
--- a/tensorflow/python/lib/core/py_func.cc
+++ b/tensorflow/python/lib/core/py_func.cc
@@ -500,6 +500,12 @@ class PyFuncOp : public OpKernel {
call.ins.push_back(ctx->input(i));
}
+ // NOTE(mrry): There is a potential time-of-check-to-time-of-use race here.
+ // because it is possible that `Py_Finalize()` could be called in another
+ // thread between this check and the call to `PyGILState_Ensure()`, which
+ // will abort the process if `Py_Finalize()` has been called. A more robust
+ // solution would be welcome, but it is not obvious how to make this work
+ // using the current Python C API.
OP_REQUIRES(
ctx, Py_IsInitialized(),
errors::FailedPrecondition("Python interpreter state is not initialized. "