From: Sangjung Woo Date: Fri, 24 Sep 2021 07:38:09 +0000 (+0900) Subject: [ML][Single] Fix the crash issue in single API X-Git-Tag: submit/tizen/20210924.083751~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e162efb0434b95eabfe5be7e019caea6fc1a6ab6;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [ML][Single] Fix the crash issue in single API Before closing the singleshot handle, the output tensor data is freed. Since inference internally is going on, this situation could cause the segmentation fault in sub-plugin part. This patch fixes that bug. Change-Id: I690b4ef941e981353f3809cc56a1f2089ef2a4e5 Signed-off-by: Sangjung Woo --- diff --git a/src/ml/ml_singleshot.cc b/src/ml/ml_singleshot.cc index da397f6a..226c7fb7 100644 --- a/src/ml/ml_singleshot.cc +++ b/src/ml/ml_singleshot.cc @@ -50,27 +50,27 @@ SingleShot::SingleShot(SingleShot&& o) SingleShot::~SingleShot() { ScopeLogger("id: %d", id_); + + int ret = ml_single_close(handle_); + if (ML_ERROR_NONE != ret) { + LoggerW("ml_single_close failed: %d (%s)", ret, get_error_message(ret)); + } // not dynamic mode uses ml_single_invoke_fast, which reuses handles, so they need to be freed if (!dynamic_mode_) { if (nullptr != tensor_data_out_handle_) { - int ret = ml_tensors_data_destroy(tensor_data_out_handle_); + ret = ml_tensors_data_destroy(tensor_data_out_handle_); if (ML_ERROR_NONE != ret) { LoggerW("ml_tensors_data_destroy failed: %d (%s)", ret, get_error_message(ret)); } } if (nullptr != tensor_info_out_handle_) { - int ret = ml_tensors_info_destroy(tensor_info_out_handle_); + ret = ml_tensors_info_destroy(tensor_info_out_handle_); if (ML_ERROR_NONE != ret) { LoggerW("ml_tensors_info_destroy failed: %d (%s)", ret, get_error_message(ret)); } } } - - int ret = ml_single_close(handle_); - if (ML_ERROR_NONE != ret) { - LoggerW("ml_single_close failed: %d (%s)", ret, get_error_message(ret)); - } } PlatformResult SingleShot::GetTensorsInfo(bool get_input_mode, ml_tensors_info_h* result) {