Prevent key-manager client crash 20/152020/1 accepted/tizen/4.0/unified/20170926.171701 submit/tizen_4.0/20170925.010818 submit/tizen_4.0/20170925.224717 submit/tizen_4.0/20170926.044845 tizen_4.0.IoT.p1_release
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Wed, 20 Sep 2017 09:19:33 +0000 (11:19 +0200)
committerDong Sun Lee <ds73.lee@samsung.com>
Mon, 25 Sep 2017 00:23:18 +0000 (00:23 +0000)
Key-manager client crashed during pthread_cancel because
try catch sections did not support stack unwind correctly.

Change-Id: I7089160603394a11d94b437bb4f80cf19b632da0
(cherry picked from commit 3eb9315f621035b8ea237096506e77dfb232d842)

src/manager/client/client-common.cpp

index d0c7a2f..7cb1108 100644 (file)
@@ -27,6 +27,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <unistd.h>
+#include <cxxabi.h>
 
 #include <dpl/errno_string.h>
 #include <dpl/log/log.h>
@@ -330,6 +331,9 @@ int try_catch(const std::function<int()> &func)
                LogError("CKM::MessageBuffer::Exception " << e.DumpToString());
        } catch (const std::exception &e) {
                LogError("STD exception " << e.what());
+       } catch (const abi::__forced_unwind &) {
+               LogDebug("abi::__forced_unwind caught. Thread cancelation.");
+               throw;
        } catch (...) {
                LogError("Unknown exception occured");
        }
@@ -347,6 +351,9 @@ int try_catch_enclosure(const std::function<int()> &func)
        } catch (const std::exception &e) {
                LogError("std exception occured: " << e.what());
                return CKMC_ERROR_UNKNOWN;
+       } catch (const abi::__forced_unwind &) {
+               LogDebug("abi::__forced_unwind caught. Thread cancelation.");
+               throw;
        } catch (...) {
                LogError("Unknown exception occured.");
                return CKMC_ERROR_UNKNOWN;
@@ -367,6 +374,9 @@ void try_catch_async(const std::function<void()> &func,
        } catch (const std::exception &e) {
                LogError("STD exception " << e.what());
                error(CKM_API_ERROR_UNKNOWN);
+       } catch (const abi::__forced_unwind &) {
+               LogDebug("abi::__forced_unwind caught. Thread cancelation.");
+               throw;
        } catch (...) {
                LogError("Unknown exception occured");
                error(CKM_API_ERROR_UNKNOWN);