fix seg. fault issue 81/298981/1
authorInki Dae <inki.dae@samsung.com>
Wed, 4 Jan 2023 05:13:28 +0000 (14:13 +0900)
committerInki Dae <inki.dae@samsung.com>
Mon, 18 Sep 2023 04:53:17 +0000 (13:53 +0900)
[Version] : 0.4.8
[Issue type] : bug fix

Fixed a seg. fault issue that it happens when a new ml single handle is
created continuously without closing a previous one by making sure
to closing previous one.

NNStreamer internally creates a new thread every time ml_simgle_open_* function
is called so which in turn, the thread creation will fail sometime later.

Change-Id: I6662bf184d2b2cd3bc6d9457ac1ca0870d77f03d
Signed-off-by: Inki Dae <inki.dae@samsung.com>
packaging/inference-engine-mlapi.spec
src/inference_engine_mlapi.cpp

index b3aa67001f61fd20e7295b9d7d0cf009ee6ee5d5..f7c28d50af2d0f68b6d3465a156ade2e5fa69d87 100644 (file)
@@ -1,6 +1,6 @@
 Name:       inference-engine-mlapi
 Summary:    ML Single API backend of NNStreamer for MediaVision
-Version:    0.4.7
+Version:    0.4.8
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 90ee0c854077842bcbd378f73beb974e937083d8..3bb0f854df84d13bbae1cfc104b0ff23093c2c37 100644 (file)
@@ -62,7 +62,8 @@ namespace MLAPIImpl
                mDesignated_outputs.clear();
                std::map<std::string, int>().swap(mDesignated_outputs);
 
-               ml_single_close(mSingle);
+               if (mSingle)
+                       ml_single_close(mSingle);
 
                if (mInputInfoHandle)
                        ml_tensors_info_destroy(mInputInfoHandle);
@@ -364,6 +365,15 @@ namespace MLAPIImpl
                customOp += GetFileCustomProp(model_str);
                LOGI("customOp: %s", customOp.c_str());
 
+               // Make sure to close previous handle because seg. fault can happen by nnstreamer sometime later
+               // if a new handle is created continuously without closing previous one - nnstreamer internally creates a new thread
+               // every time ml_single_open_full function is called, which in turn thread creation request can fail.
+               if (mSingle) {
+                       ml_single_close(mSingle);
+                       mSingle = NULL;
+                       LOGI("Closed previous ML Single API handle.");
+               }
+
                int err = ml_single_open_full(&mSingle, model_str.c_str(), in_info, out_info,
                                                                 nnfw_type, nnfw_hw, customOp.c_str());
                if (err != ML_ERROR_NONE) {