aboutsummaryrefslogtreecommitdiff
path: root/RequestThread.cpp
diff options
context:
space:
mode:
authorsurmeh01 <surabhi.mehta@arm.com>2018-05-17 14:11:25 +0100
committertelsoa01 <telmo.soares@arm.com>2018-05-23 16:23:49 +0100
commit49b9e100bfbb3b8da01472a0ff48b2bd92944e01 (patch)
tree1a998fa12f665ff0a15b299d8bae5590e0aed884 /RequestThread.cpp
parent28adb40e1bb1d3f3a06a7f333f7f2a4f42d3ed4b (diff)
downloadandroid-nn-driver-49b9e100bfbb3b8da01472a0ff48b2bd92944e01.tar.gz
Release 18.05
Diffstat (limited to 'RequestThread.cpp')
-rw-r--r--RequestThread.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/RequestThread.cpp b/RequestThread.cpp
index 708a46c8..abaee90c 100644
--- a/RequestThread.cpp
+++ b/RequestThread.cpp
@@ -26,12 +26,26 @@ RequestThread::RequestThread()
RequestThread::~RequestThread()
{
ALOGV("RequestThread::~RequestThread()");
- // post an EXIT message to the thread
- std::shared_ptr<AsyncExecuteData> nulldata(nullptr);
- auto pMsg = std::make_shared<ThreadMsg>(ThreadMsgType::EXIT, nulldata);
- PostMsg(pMsg);
- // Wait for the thread to terminate, it is deleted automatically
- m_Thread->join();
+
+ try
+ {
+ // Coverity fix: The following code may throw an exception of type std::length_error.
+
+ // This code is meant to to terminate the inner thread gracefully by posting an EXIT message
+ // to the thread's message queue. However, according to Coverity, this code could throw an exception and fail.
+ // Since only one static instance of RequestThread is used in the driver (in ArmnnPreparedModel),
+ // this destructor is called only when the application has been closed, which means that
+ // the inner thread will be terminated anyway, although abruptly, in the event that the destructor code throws.
+ // Wrapping the destructor's code with a try-catch block simply fixes the Coverity bug.
+
+ // Post an EXIT message to the thread
+ std::shared_ptr<AsyncExecuteData> nulldata(nullptr);
+ auto pMsg = std::make_shared<ThreadMsg>(ThreadMsgType::EXIT, nulldata);
+ PostMsg(pMsg);
+ // Wait for the thread to terminate, it is deleted automatically
+ m_Thread->join();
+ }
+ catch (const std::exception&) { } // Swallow any exception.
}
void RequestThread::PostMsg(ArmnnPreparedModel* model,