From 048f5ffc3828657c7d320d05e4f9c502acb922ad Mon Sep 17 00:00:00 2001 From: Bartlomiej Grzelewski Date: Wed, 20 Sep 2017 11:19:33 +0200 Subject: [PATCH] Prevent key-manager client crash 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/manager/client/client-common.cpp b/src/manager/client/client-common.cpp index d0c7a2f..7cb1108 100644 --- a/src/manager/client/client-common.cpp +++ b/src/manager/client/client-common.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -330,6 +331,9 @@ int try_catch(const std::function &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 &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 &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); -- 2.7.4