Skip to content

Commit

Permalink
Fixed dlerror KW issue (openvinotoolkit#8184)
Browse files Browse the repository at this point in the history
  • Loading branch information
apankratovantonp authored Oct 25, 2021
1 parent e0f88b7 commit 8741b15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,3 @@ class SoPointerTests : public ::testing::Test {};
TEST_F(SoPointerTests, UnknownPlugin) {
ASSERT_THROW(SOPointer<InferenceEngine::details::UnknownPlugin>{std::string{"UnknownPlugin"}}, Exception);
}

TEST_F(SoPointerTests, UnknownPluginExceptionStr) {
try {
SOPointer<InferenceEngine::details::UnknownPlugin>(std::string{"UnknownPlugin"});
}
catch (Exception &e) {
ASSERT_STR_CONTAINS(e.what(), "Cannot load library 'UnknownPlugin':");
ASSERT_STR_DOES_NOT_CONTAIN(e.what(), "path:");
ASSERT_STR_DOES_NOT_CONTAIN(e.what(), "from CWD:");
}
}
11 changes: 9 additions & 2 deletions openvino/util/src/os/lin/lin_shared_object_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ std::shared_ptr<void> load_shared_object(const char* path) {
auto shared_object = std::shared_ptr<void>{dlopen(path, RTLD_NOW), [](void* shared_object) {
if (shared_object != nullptr) {
if (0 != dlclose(shared_object)) {
std::cerr << "dlclose failed: " << dlerror() << std::endl;
std::cerr << "dlclose failed";
if (auto error = dlerror()) {
std::cerr << ": " << error;
}
std::cerr << std::endl;
}
}
}};
if (!shared_object) {
std::stringstream ss;
ss << "Cannot load library '" << path << "': " << dlerror();
ss << "Cannot load library '" << path;
if (auto error = dlerror()) {
ss << ": " << error;
}
throw std::runtime_error(ss.str());
}
return shared_object;
Expand Down

0 comments on commit 8741b15

Please sign in to comment.