Revert loading of plugins strictly by absolute paths (#14333)
* Revert "Load plugin libraries safely (#14034)" This reverts commit97878dee34
. * Revert "Plugins absolute path loading leftovers (#14299)" This reverts commit9ba304de72
. * Revert "Add `loadSOSafelyThrowIfRelativePath` test (#14311)" This reverts commit3e9f185e5d
. * Revert "Filter out samples tests on GNA for Debian (#14195)" This reverts commit57e630bd8f
.
This commit is contained in:
parent
ebf04b17d1
commit
0e9f2bb7d8
@ -424,8 +424,7 @@ jobs:
|
|||||||
export IE_APP_PYTHON_PATH=$(PYTHON_SAMPLES_INSTALL_DIR)/
|
export IE_APP_PYTHON_PATH=$(PYTHON_SAMPLES_INSTALL_DIR)/
|
||||||
export SHARE=$(INSTALL_TEST_DIR)/smoke_tests/samples_smoke_tests_data/
|
export SHARE=$(INSTALL_TEST_DIR)/smoke_tests/samples_smoke_tests_data/
|
||||||
export WORKSPACE=$(INSTALL_DIR)
|
export WORKSPACE=$(INSTALL_DIR)
|
||||||
# GNA isn't a part of Debian package, so filter out that tests
|
python3 -m pytest $(INSTALL_TEST_DIR)/smoke_tests/ --env_conf $(INSTALL_TEST_DIR)/smoke_tests/env_config.yml -s --junitxml=$(INSTALL_TEST_DIR)/TEST-SamplesSmokeTests.xml
|
||||||
python3 -m pytest $(INSTALL_TEST_DIR)/smoke_tests/ -k "not GNA" --env_conf $(INSTALL_TEST_DIR)/smoke_tests/env_config.yml -s --junitxml=$(INSTALL_TEST_DIR)/TEST-SamplesSmokeTests.xml
|
|
||||||
displayName: 'Samples Smoke Tests'
|
displayName: 'Samples Smoke Tests'
|
||||||
continueOnError: false
|
continueOnError: false
|
||||||
|
|
||||||
|
@ -33,9 +33,6 @@ add_library(${TARGET_NAME} STATIC ${LIBRARY_SRC} ${PUBLIC_HEADERS})
|
|||||||
add_library(openvino::util ALIAS ${TARGET_NAME})
|
add_library(openvino::util ALIAS ${TARGET_NAME})
|
||||||
|
|
||||||
target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS})
|
target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS})
|
||||||
if (WIN32)
|
|
||||||
target_link_libraries(${TARGET_NAME} PRIVATE Shlwapi)
|
|
||||||
endif()
|
|
||||||
target_include_directories(${TARGET_NAME} PUBLIC
|
target_include_directories(${TARGET_NAME} PUBLIC
|
||||||
$<BUILD_INTERFACE:${UTIL_INCLUDE_DIR}>)
|
$<BUILD_INTERFACE:${UTIL_INCLUDE_DIR}>)
|
||||||
|
|
||||||
|
@ -23,15 +23,6 @@ namespace util {
|
|||||||
*/
|
*/
|
||||||
std::shared_ptr<void> load_shared_object(const char* path);
|
std::shared_ptr<void> load_shared_object(const char* path);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Loads a library with absolute path specified.
|
|
||||||
* Prevents library search in working directory, environment
|
|
||||||
* variables etc.
|
|
||||||
* @param path Full path to the plugin library
|
|
||||||
* @return Reference to shared object
|
|
||||||
*/
|
|
||||||
std::shared_ptr<void> load_shared_object_safely(const char* path);
|
|
||||||
|
|
||||||
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
|
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
|
||||||
/**
|
/**
|
||||||
* @brief Loads a library with the wide char name specified.
|
* @brief Loads a library with the wide char name specified.
|
||||||
@ -39,15 +30,6 @@ std::shared_ptr<void> load_shared_object_safely(const char* path);
|
|||||||
* @return Reference to shared object
|
* @return Reference to shared object
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<void> load_shared_object(const wchar_t* path);
|
std::shared_ptr<void> load_shared_object(const wchar_t* path);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Loads a library with wide char absolute path specified.
|
|
||||||
* Prevents library search in working directory, environment
|
|
||||||
* variables etc.
|
|
||||||
* @param path Full path to the plugin library
|
|
||||||
* @return Reference to shared object
|
|
||||||
*/
|
|
||||||
std::shared_ptr<void> load_shared_object_safely(const wchar_t* path);
|
|
||||||
#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
|
#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
|
||||||
/**
|
/**
|
||||||
* @brief Searches for a function symbol in the loaded module
|
* @brief Searches for a function symbol in the loaded module
|
||||||
|
@ -12,14 +12,6 @@
|
|||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace util {
|
namespace util {
|
||||||
std::shared_ptr<void> load_shared_object_safely(const char* path) {
|
|
||||||
if (path == nullptr)
|
|
||||||
throw std::runtime_error("Cannot load library: path isn't specified.");
|
|
||||||
if (path[0] == '/')
|
|
||||||
return load_shared_object(path);
|
|
||||||
throw std::runtime_error("Cannot load library: path '" + static_cast<std::string>(path) + "' is not absolute.");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<void> load_shared_object(const char* path) {
|
std::shared_ptr<void> load_shared_object(const char* path) {
|
||||||
auto shared_object = std::shared_ptr<void>{dlopen(path, RTLD_NOW), [](void* shared_object) {
|
auto shared_object = std::shared_ptr<void>{dlopen(path, RTLD_NOW), [](void* shared_object) {
|
||||||
if (shared_object != nullptr) {
|
if (shared_object != nullptr) {
|
||||||
@ -44,10 +36,6 @@ std::shared_ptr<void> load_shared_object(const char* path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
|
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
|
||||||
std::shared_ptr<void> load_shared_object_safely(const wchar_t* path) {
|
|
||||||
return load_shared_object_safely(ov::util::wstring_to_string(path).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<void> load_shared_object(const wchar_t* path) {
|
std::shared_ptr<void> load_shared_object(const wchar_t* path) {
|
||||||
return load_shared_object(ov::util::wstring_to_string(path).c_str());
|
return load_shared_object(ov::util::wstring_to_string(path).c_str());
|
||||||
}
|
}
|
||||||
|
@ -70,18 +70,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Shlwapi.h>
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace util {
|
namespace util {
|
||||||
std::shared_ptr<void> load_shared_object_safely(const char* path) {
|
|
||||||
if (path == nullptr)
|
|
||||||
throw std::runtime_error("Cannot load library: path isn't specified.");
|
|
||||||
if (!PathIsRelativeA(path))
|
|
||||||
return load_shared_object(path);
|
|
||||||
throw std::runtime_error("Cannot load library: path '" + static_cast<std::string>(path) + "' is not absolute.");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<void> load_shared_object(const char* path) {
|
std::shared_ptr<void> load_shared_object(const char* path) {
|
||||||
void* shared_object = nullptr;
|
void* shared_object = nullptr;
|
||||||
using GetDllDirectoryA_Fnc = DWORD (*)(DWORD, LPSTR);
|
using GetDllDirectoryA_Fnc = DWORD (*)(DWORD, LPSTR);
|
||||||
@ -133,14 +124,6 @@ std::shared_ptr<void> load_shared_object(const char* path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
|
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
|
||||||
std::shared_ptr<void> load_shared_object_safely(const wchar_t* path) {
|
|
||||||
if (path == nullptr)
|
|
||||||
throw std::runtime_error("Cannot load library: path isn't specified.");
|
|
||||||
if (!PathIsRelativeW(path))
|
|
||||||
return load_shared_object(path);
|
|
||||||
throw std::runtime_error("Cannot load library: path '" + ov::util::wstring_to_string(std::wstring(path)) + "' is not absolute.");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<void> load_shared_object(const wchar_t* path) {
|
std::shared_ptr<void> load_shared_object(const wchar_t* path) {
|
||||||
void* shared_object = nullptr;
|
void* shared_object = nullptr;
|
||||||
using GetDllDirectoryW_Fnc = DWORD (*)(DWORD, LPWSTR);
|
using GetDllDirectoryW_Fnc = DWORD (*)(DWORD, LPWSTR);
|
||||||
|
@ -603,10 +603,10 @@ public:
|
|||||||
* @param plugin_name Name of a plugin. Depending on platform, `plugin_name` is wrapped with shared library suffix
|
* @param plugin_name Name of a plugin. Depending on platform, `plugin_name` is wrapped with shared library suffix
|
||||||
* and prefix to identify library full name.
|
* and prefix to identify library full name.
|
||||||
* For example, on Linux platform, plugin name specified as `plugin_name` will be wrapped as `libplugin_name.so`.
|
* For example, on Linux platform, plugin name specified as `plugin_name` will be wrapped as `libplugin_name.so`.
|
||||||
* Note that plugin should be located in one of next places:
|
* Plugin search algorithm:
|
||||||
* - the same directory as OpenVINO runtime library as is
|
* - If plugin is located in the same directory as OpenVINO runtime library, it will be used.
|
||||||
* - the same directory as OpenVINO runtime library inside openvino-<version> subdirectory
|
* - If no, plugin is tried to be loaded from paths pointed by PATH/LD_LIBRARY_PATH/DYLD_LIBRARY_PATH
|
||||||
* (environment variables like PATH/LD_LIBRARY_PATH/DYLD_LIBRARY_PATH are ignored)
|
* environment variables depending on the platform.
|
||||||
*
|
*
|
||||||
* @param device_name Device name to register a plugin for.
|
* @param device_name Device name to register a plugin for.
|
||||||
*/
|
*/
|
||||||
|
@ -107,6 +107,7 @@ ov::util::FilePath getPluginPath(const std::string& pluginName, bool needAddSuff
|
|||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
try {
|
try {
|
||||||
|
// dlopen works with absolute paths; otherwise searches from LD_LIBRARY_PATH
|
||||||
pluginPath = ov::util::to_file_path(ov::util::get_absolute_file_path(pluginName));
|
pluginPath = ov::util::to_file_path(ov::util::get_absolute_file_path(pluginName));
|
||||||
} catch (const std::runtime_error&) {
|
} catch (const std::runtime_error&) {
|
||||||
// failed to resolve absolute path; not critical
|
// failed to resolve absolute path; not critical
|
||||||
@ -133,7 +134,11 @@ ov::util::FilePath getPluginPath(const std::string& pluginName, bool needAddSuff
|
|||||||
|
|
||||||
// 2. in the openvino.so location
|
// 2. in the openvino.so location
|
||||||
absFilePath = FileUtils::makePath(ieLibraryPath, pluginPath);
|
absFilePath = FileUtils::makePath(ieLibraryPath, pluginPath);
|
||||||
return absFilePath;
|
if (FileUtils::fileExist(absFilePath))
|
||||||
|
return absFilePath;
|
||||||
|
|
||||||
|
// 3. in LD_LIBRARY_PATH on Linux / PATH on Windows
|
||||||
|
return pluginPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T = ie::Parameter>
|
template <typename T = ie::Parameter>
|
||||||
@ -1156,7 +1161,7 @@ public:
|
|||||||
desc.pluginCreateFunc(plugin_impl);
|
desc.pluginCreateFunc(plugin_impl);
|
||||||
plugin = InferencePlugin{plugin_impl, {}};
|
plugin = InferencePlugin{plugin_impl, {}};
|
||||||
} else {
|
} else {
|
||||||
so = ov::util::load_shared_object_safely(desc.libraryLocation.c_str());
|
so = ov::util::load_shared_object(desc.libraryLocation.c_str());
|
||||||
std::shared_ptr<ie::IInferencePlugin> plugin_impl;
|
std::shared_ptr<ie::IInferencePlugin> plugin_impl;
|
||||||
reinterpret_cast<InferenceEngine::CreatePluginEngineFunc*>(
|
reinterpret_cast<InferenceEngine::CreatePluginEngineFunc*>(
|
||||||
ov::util::get_symbol(so, InferenceEngine::create_plugin_function))(plugin_impl);
|
ov::util::get_symbol(so, InferenceEngine::create_plugin_function))(plugin_impl);
|
||||||
|
@ -60,9 +60,3 @@ TEST_F(SharedObjectOVTests, canCallExistedMethod) {
|
|||||||
std::shared_ptr<InferenceEngine::IInferencePlugin> ptr;
|
std::shared_ptr<InferenceEngine::IInferencePlugin> ptr;
|
||||||
EXPECT_NO_THROW(factory(ptr));
|
EXPECT_NO_THROW(factory(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SharedObjectOVTests, loadSOSafelyThrowIfOnlyLibName) {
|
|
||||||
std::string libraryName = FileUtils::makePluginLibraryName<char>({}, std::string("mock_engine") + IE_BUILD_POSTFIX);
|
|
||||||
|
|
||||||
EXPECT_THROW(ov::util::load_shared_object_safely(libraryName.c_str()), std::runtime_error);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user