diff options
author | 2018-05-22 12:46:30 -0700 | |
---|---|---|
committer | 2018-05-22 12:49:03 -0700 | |
commit | bf6644f9d274f549707d3f2a80c77e5eda163ebb (patch) | |
tree | fc538e15e0ff045a32a798121cf34a3b81294faa /tensorflow | |
parent | a4c9efe6a5bf143f844b1cffbdc839c399620b9b (diff) |
Fix memory leak when going from the fast path to the slow path in eager
Fixes #19385
PiperOrigin-RevId: 197607384
Diffstat (limited to 'tensorflow')
-rw-r--r-- | tensorflow/python/eager/pywrap_tfe_src.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tensorflow/python/eager/pywrap_tfe_src.cc b/tensorflow/python/eager/pywrap_tfe_src.cc index 62deb41e9b..9885b3d3d7 100644 --- a/tensorflow/python/eager/pywrap_tfe_src.cc +++ b/tensorflow/python/eager/pywrap_tfe_src.cc @@ -49,8 +49,7 @@ using AttrToInputsMap = tensorflow::gtl::FlatMap<string, tensorflow::gtl::InlinedVector<InputInfo, 4>>; -tensorflow::mutex all_attr_to_input_maps_lock( - tensorflow::LINKER_INITIALIZED); +tensorflow::mutex all_attr_to_input_maps_lock(tensorflow::LINKER_INITIALIZED); tensorflow::gtl::FlatMap<string, AttrToInputsMap*>* GetAllAttrToInputsMaps() { static auto* all_attr_to_input_maps = new tensorflow::gtl::FlatMap<string, AttrToInputsMap*>; @@ -754,7 +753,7 @@ PyObject* TFE_Py_RegisterBackwardFunctionGetter(PyObject* e) { void RaiseFallbackException(const char* message) { if (fallback_exception_class != nullptr) { - PyErr_SetObject(fallback_exception_class, Py_BuildValue("s", message)); + PyErr_SetString(fallback_exception_class, message); return; } @@ -772,8 +771,9 @@ int MaybeRaiseExceptionFromTFStatus(TF_Status* status, PyObject* exception) { if (exception == nullptr) { tensorflow::mutex_lock l(exception_class_mutex); if (exception_class != nullptr) { - PyErr_SetObject(exception_class, - Py_BuildValue("si", msg, TF_GetCode(status))); + tensorflow::Safe_PyObjectPtr val( + Py_BuildValue("si", msg, TF_GetCode(status))); + PyErr_SetObject(exception_class, val.get()); return -1; } else { exception = PyExc_RuntimeError; @@ -791,7 +791,8 @@ int MaybeRaiseExceptionFromStatus(const tensorflow::Status& status, if (exception == nullptr) { tensorflow::mutex_lock l(exception_class_mutex); if (exception_class != nullptr) { - PyErr_SetObject(exception_class, Py_BuildValue("si", msg, status.code())); + tensorflow::Safe_PyObjectPtr val(Py_BuildValue("si", msg, status.code())); + PyErr_SetObject(exception_class, val.get()); return -1; } else { exception = PyExc_RuntimeError; |