Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[NPU] Fix coverity for uncaught exception in destructor (#33936)

Dan Liuea23a7153cf8
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
index 3643c43c4de..9cf98f42795 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
@@ -696,7 +696,7 @@ struct NUM_STREAMS final : OptionBase<NUM_STREAMS, ov::streams::Num> {
static void validateValue(const ov::streams::Num& num) {
if (defaultValue() != num && ov::streams::AUTO != num) {
- throw std::runtime_error("NUM_STREAMS can not be set");
+ OPENVINO_THROW("NUM_STREAMS can not be set");
}
}
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/custom_stream_buffer.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/custom_stream_buffer.hpp
index 8c4ff23b0d3..b0e8f4501a1 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/custom_stream_buffer.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/custom_stream_buffer.hpp
@@ -39,7 +39,7 @@ private:
return m_size;
} else {
// No seek support
- throw std::runtime_error("Seek operation is not supported for counting_streambuf");
+ OPENVINO_THROW("Seek operation is not supported for counting_streambuf");
}
}
@@ -71,7 +71,7 @@ private:
return std::distance(startIt, writeIt);
} else {
// No seek support
- throw std::runtime_error("Seek operation is not supported for writer_streambuf");
+ OPENVINO_THROW("Seek operation is not supported for writer_streambuf");
}
}
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp
index dd1f9e4fdb0..f1829565a21 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp
@@ -407,8 +407,15 @@ VCLCompilerImpl::VCLCompilerImpl() : _logHandle(nullptr), _logger("VCLCompilerIm
VCLCompilerImpl::~VCLCompilerImpl() {
if (_compilerHandle) {
- THROW_ON_FAIL_FOR_VCL("vclCompilerDestroy", vclCompilerDestroy(_compilerHandle), _logHandle);
+ vcl_result_t result = vclCompilerDestroy(_compilerHandle);
+ _compilerHandle = nullptr;
+ if (result != VCL_RESULT_SUCCESS) {
+ _logger.warning("Failed to destroy VCL compiler: result 0x%x - %s",
+ result,
+ getLatestVCLLog(_logHandle).c_str());
+ }
}
+
if (_logHandle) {
_logHandle = nullptr; // Log handle is released automatically with the compiler
}
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/mem_usage.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/mem_usage.cpp
index ebb0d37e689..9572916032e 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/mem_usage.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/mem_usage.cpp
@@ -5,6 +5,7 @@
// clang-format off
#include "mem_usage.hpp"
+#include "openvino/core/except.hpp"
#if defined _WIN32
@@ -17,7 +18,7 @@
int64_t intel_npu::get_peak_memory_usage() {
PROCESS_MEMORY_COUNTERS mem_counters;
if (!GetProcessMemoryInfo(GetCurrentProcess(), &mem_counters, sizeof(mem_counters))) {
- throw std::runtime_error("Can't get system memory values");
+ OPENVINO_THROW("Can't get system memory values");
}
// Linux tracks memory usage in pages and then converts them to kB.
@@ -59,7 +60,7 @@ int64_t intel_npu::get_peak_memory_usage() {
}
if (!mem_values_found) {
- throw std::runtime_error("Can't get system memory values");
+ OPENVINO_THROW("Can't get system memory values");
}
// please note then we calculate difference
diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_npu/tests/functional/shared_tests_instances/skip_tests_config.cpp
index 95cbc13fd95..8c44c493e73 100644
--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/skip_tests_config.cpp
+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/skip_tests_config.cpp
@@ -250,7 +250,7 @@ std::vector<std::string> disabledTestPatterns() {
// Error returned from pugixml, fallback to legacy skips
if (!xmlResult.error_msg.empty()) {
_log.error(xmlResult.error_msg.c_str());
- throw std::runtime_error("No skip filters are applied");
+ OPENVINO_THROW("No skip filters are applied");
}
pugi::xml_document& xmlSkipConfig = *xmlResult.xml;