From d62520f9a1b54883a11d9a5da93e068300a9fb40 Mon Sep 17 00:00:00 2001 From: Superpiffer Date: Wed, 1 Feb 2023 16:52:49 +0100 Subject: [PATCH] Removed use of tf.Status static instance In multithreading .NET 4.8 applications, sometimes in Session finalizer the method c_api.TF_DeleteSession find f.Status static instance already disposed for some reason. No problem for .NET 6 application or with a single thread. --- src/TensorFlowNET.Core/Sessions/BaseSession.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TensorFlowNET.Core/Sessions/BaseSession.cs b/src/TensorFlowNET.Core/Sessions/BaseSession.cs index 1c9ed2a01..0051a6b33 100644 --- a/src/TensorFlowNET.Core/Sessions/BaseSession.cs +++ b/src/TensorFlowNET.Core/Sessions/BaseSession.cs @@ -291,7 +291,7 @@ private void _extend_graph() protected override void DisposeUnmanagedResources(IntPtr handle) { // c_api.TF_CloseSession(handle, tf.Status.Handle); - c_api.TF_DeleteSession(handle, tf.Status.Handle); + c_api.TF_DeleteSession(handle, c_api.TF_NewStatus()); } } }