From: Inki Dae Date: Wed, 4 Jan 2023 05:13:28 +0000 (+0900) Subject: fix seg. fault issue X-Git-Tag: accepted/tizen/7.0/unified/20230920.022050~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d7103d4089f499fd1380c21a10d27b2d6d2cb545;p=platform%2Fcore%2Fmultimedia%2Finference-engine-mlapi.git fix seg. fault issue [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 --- diff --git a/packaging/inference-engine-mlapi.spec b/packaging/inference-engine-mlapi.spec index b3aa670..f7c28d5 100644 --- a/packaging/inference-engine-mlapi.spec +++ b/packaging/inference-engine-mlapi.spec @@ -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 diff --git a/src/inference_engine_mlapi.cpp b/src/inference_engine_mlapi.cpp index 90ee0c8..3bb0f85 100644 --- a/src/inference_engine_mlapi.cpp +++ b/src/inference_engine_mlapi.cpp @@ -62,7 +62,8 @@ namespace MLAPIImpl mDesignated_outputs.clear(); std::map().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) {