From 43625abe917a4712e8cdad9c7b49c9875f302a68 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 1c9ed2a0..0051a6b3 100644 --- a/src/TensorFlowNET.Core/Sessions/BaseSession.cs +++ b/src/TensorFlowNET.Core/Sessions/BaseSession.cs @@ -291,7 +291,7 @@ namespace Tensorflow 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()); } } }