{"id":163745,"date":"2012-12-24T15:24:04","date_gmt":"2012-12-24T11:24:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=163745"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=163745","title":{"rendered":"<span class=\"post_title\">\u041e\u0441\u043e\u0431\u0435\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0439\u0438 \u0432 Windows<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u043d\u0435\u0434\u0430\u0432\u043d\u0438\u0439 \u0442\u043e\u043f\u0438\u043a &quot;<a href=\"http:\/\/habrahabr.ru\/post\/163393\/\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 try \u2014 catch \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438<\/a>&quot; \u0440\u0435\u0448\u0438\u043b \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0438 \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/7a6\/67a\/7b2\/7a667a7b231f31e16962a04e2e5dfa77.jpg\" align=\"right\"\/> \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 callstack\u2019\u0430 \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u0431\u044b\u043b\u043e \u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e <br \/>  \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u043c\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c\u0438 (MS Windows). \u0412 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0442.\u043a. \u044d\u0442\u043e \u0442\u044f\u043d\u0435\u0442 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 (\u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445\u0441\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0420\u0438\u0445\u0442\u0435\u0440\u0430, MSDN \u0438 wasm.ru). \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 <code>minidump<\/code>\u2019\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"http:\/\/code.google.com\/p\/crashrpt\/\">CrashRpt <\/a>\u0438\u043b\u0438 <a href=\"http:\/\/code.google.com\/p\/google-breakpad\/\">google-breakpad<\/a>), \u0442\u0430\u043a \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u043e\u0441\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440.<\/p>\n<p>  \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0441\u0442\u0435\u043a\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u2014 \u0440\u0435\u0448\u0430\u0442\u044c \u0432\u0430\u043c. \u041c\u043e\u0436\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u043e\u043c, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b \u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 (\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0441 \u0438\u0445 \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b).<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/h4>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0436\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u2014 \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u041d\u0435 \u0432\u0441\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432\u0430\u0448\u0438, \u0438 \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043a\u043b\u0430\u0441\u0441 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <code>try-catch<\/code>, \u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>__try-__except<\/code>.<\/p>\n<p>  \u0411\u0443\u0434\u0435\u043c \u0438\u0434\u0442\u0438 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0432 \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e. \u0421\u0442\u0435\u043a \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432 \u0444\u0438\u043b\u044c\u0442\u0440\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u043e\u0432. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u043c \u0432 \u0431\u043b\u043e\u043a <code>catch<\/code> \u0441\u0442\u0435\u043a \u0443\u0436\u0435 \u0440\u0430\u0441\u043a\u0440\u0443\u0447\u0435\u043d, \u0430 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u044b \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438\u0441\u044c \u0441\u0442\u0435\u043a \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c. \u041d\u043e, \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 <code>try-catch<\/code> \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 <code>__try-__except<\/code>, \u0442\u043e, \u0434\u0430\u0436\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u0444\u0438\u043b\u044c\u0442\u0440, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0432 <code>__except<\/code>. \u0422\u0443\u0442 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043d\u043e \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440? \u0415\u0441\u043b\u0438 \u0444\u0438\u043b\u044c\u0442\u0440 \u0432\u0435\u0440\u043d\u0435\u0442 <code>EXCEPTION_EXECUTE_HANDLER<\/code>, \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u0434\u043e\u0439\u0434\u0435\u043c \u0434\u043e <code>try-catch<\/code>. \u0427\u0442\u043e \u0436\u0435, \u0432\u0435\u0440\u043d\u0435\u043c <code>EXCEPTION_CONTINUE_SEARCH<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0431\u0443\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0438\u043b\u044c\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0435\u0442 <code>EXCEPTION_EXECUTE_HANDLER<\/code>. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u044b \u0434\u043e\u0439\u0434\u0435\u043c \u0434\u043e <code>try-catch<\/code>, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u0439\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u0441\u0442\u0435\u043a\u0443, \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442 <code>try-catch<\/code> \u0438 \u0442\u0430\u043a \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442 <code>__except<\/code> \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c <code>EXCEPTION_EXECUTE_HANDLER<\/code>. \u0425\u043e\u0440\u043e\u0448\u043e, \u0442\u043e\u0433\u0434\u0430 \u043e\u0431\u0435\u0440\u043d\u0435\u043c <code>try-catch<\/code> \u0432 <code>__try-__except(EXCEPTION_EXECUTE_HANDLER)<\/code>.<\/p>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u043b\u043e\u043a  <\/p>\n<pre><code class=\"cpp\">__except(filter()\/*-&gt; EXCEPTION_CONTINUE_SEARCH*\/) {  \/*\u044d\u0442\u043e\u0442 \u0431\u043b\u043e\u043a*\/ }<\/code><\/pre>\n<p>\u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0438\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c (\u044d\u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439):  <\/p>\n<pre><code class=\"cpp\">__try {  try  {    __try    {      useful_unsafe_function();    }    __except(filter()\/*-&gt; EXCEPTION_CONTINUE_SEARCH*\/)    {      \/\/ this block will be never executed    }  }  catch(const your_lib::Exception& ex)  {  }  catch(const std::exception& ex)  {  }  catch(...)  {  } } __except(EXCEPTION_EXECUTE_HANDLER) { }<\/code><\/pre>\n<p>  <\/p>\n<h4>\u041f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0433\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0438 \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0432\u0441\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043d\u0430\u0433\u0440\u043e\u043c\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432 \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<p>  \u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043e\u0431\u0435\u0440\u0442\u043a\u0435:  <\/p>\n<ul>\n<li>\u0412 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u043d\u0438 \u043e\u0434\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u0441\u044f.<\/li>\n<li>\u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (<code>function&lt;void()&gt;<\/code>)<\/li>\n<li>\u0421\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0442\u043e \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0431 \u044d\u0442\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c, \u0432\u0435\u0440\u043d\u0443\u0432 <code>false<\/code>.<\/li>\n<\/ul>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0430\u0448 \u043c\u0435\u0442\u043e\u0434 \u2014 \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430, \u0438\/\u0438\u043b\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0442\u043e-\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\/\u0438\u043b\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043e\u0431\u0435\u0440\u0442\u043a\u0438:<\/p>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043d\u0430\u0448\u0435\u0439 \u043e\u0431\u0435\u0440\u0442\u043a\u0438:  <\/p>\n<pre><code class=\"cpp\"> struct SafeExecutor  {    typedef boost::function&lt;void()&gt; TDoDelegate;    SafeExecutor(TDoDelegate doDelegate);    \/\/ true - the everything is successful    \/\/ false - otherwise    bool Do();  private:    bool DoCPlusPlusExceptionWrapper();    bool DoWorkWrapper();  private:    TDoDelegate m_DoDelegate;  };<\/code><\/pre>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>Filter<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u0438 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>EXCEPTION_CONTINUE_SEARCH<\/code>:  <\/p>\n<pre><code class=\"cpp\"> LONG Filter( PEXCEPTION_POINTERS pep )  {    \/\/ pep-&gt;ExceptionRecord-&gt;ExceptionCode    \/\/ pep-&gt;ExceptionRecord-&gt;ExceptionAddress    \/\/ GetModules();    \/\/ GetCallStack();    return EXCEPTION_CONTINUE_SEARCH;  }<\/code><\/pre>\n<p>  \u0421\u0430\u043c\u0430\u044f \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439.  <\/p>\n<pre><code class=\"cpp\">bool SafeExecutor::Do() {  bool AbnornalTermination = false;  bool IsExecSuccessful = true;  {    __try    {      IsExecSuccessful = DoCPlusPlusExceptionWrapper();    }    __except(EXCEPTION_EXECUTE_HANDLER)    {      AbnornalTermination = true;    }  }  return !AbnornalTermination  && IsExecSuccessful; }<\/code><\/pre>\n<p>  \u0412\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u2014 \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u00abC++-\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u00bb \u0438 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439.  <\/p>\n<pre><code class=\"cpp\">bool SafeExecutor::DoCPlusPlusExceptionWrapper() {  bool res = true;  try  {    res = DoWorkWrapper();  }  catch(std::exception& \/*ex*\/)  {    \/\/ smth like log(ex.what());    \/\/assert(false);    res = false;  }  catch(...)  {    \/\/ smth like log(&quot;unknown sw-exception);    \/\/assert(false);    res = false;  }  return res; }<\/code><\/pre>\n<p>  \u0418 \u0442\u0440\u0435\u0442\u044c\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>Filter<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u0432\u043e\u0432.  <\/p>\n<pre><code class=\"cpp\">bool SafeExecutor::DoWorkWrapper() {  bool res = false;  if (!m_DoDelegate.empty())  {    __try    {      m_DoDelegate();      res = true;    } __except(Filter(GetExceptionInformation()))  \/\/ we must dump callstack inside this Filter    {      \/\/ never be executed because Filter always returns `CONTINUE_SEARCH`    }  }  return res; }<\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 <a href=\"http:\/\/code.google.com\/p\/googletest\/\">google test framework<\/a>.<\/p>\n<p>  \u0410\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:  <\/p>\n<pre><code class=\"cpp\"> int HWUnsafe()  {    int z = 0;    return 1\/z;  }   TEST(HWUnsafe, SafeExecutor)  {    SafeExecutorNS::SafeExecutor se(HWUnsafe);    ASSERT_FALSE(se.Do());  }<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:  <\/p>\n<pre><code class=\"cpp\"> int SWUnsafe1()  {    int z = 1;    throw std::exception();    return 1\/z;  }   TEST(SW_std_ex, SafeExecutor)  {    SafeExecutorNS::SafeExecutor se(SWUnsafe1);    ASSERT_FALSE(se.Do());  }<\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0440\u043e\u0433\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0432 \u043f\u043b\u0430\u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u043f\u0440\u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0435.    \t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/163745\/\"> http:\/\/habrahabr.ru\/post\/163745\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u043d\u0435\u0434\u0430\u0432\u043d\u0438\u0439 \u0442\u043e\u043f\u0438\u043a &quot;<a href=\"http:\/\/habrahabr.ru\/post\/163393\/\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 try \u2014 catch \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438<\/a>&quot; \u0440\u0435\u0448\u0438\u043b \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0438 \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/7a6\/67a\/7b2\/7a667a7b231f31e16962a04e2e5dfa77.jpg\" align=\"right\"\/> \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 callstack\u2019\u0430 \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u0431\u044b\u043b\u043e \u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e <br \/>  \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u043c\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c\u0438 (MS Windows). \u0412 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0442.\u043a. \u044d\u0442\u043e \u0442\u044f\u043d\u0435\u0442 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 (\u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445\u0441\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0420\u0438\u0445\u0442\u0435\u0440\u0430, MSDN \u0438 wasm.ru). \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 <code>minidump<\/code>\u2019\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"http:\/\/code.google.com\/p\/crashrpt\/\">CrashRpt <\/a>\u0438\u043b\u0438 <a href=\"http:\/\/code.google.com\/p\/google-breakpad\/\">google-breakpad<\/a>), \u0442\u0430\u043a \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u043e\u0441\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440.<\/p>\n<p>  \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0441\u0442\u0435\u043a\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u2014 \u0440\u0435\u0448\u0430\u0442\u044c \u0432\u0430\u043c. \u041c\u043e\u0436\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u043e\u043c, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b \u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 (\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0441 \u0438\u0445 \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b).  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-163745","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/163745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=163745"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/163745\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=163745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=163745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=163745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}