{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/25069096","id":25069096,"diff_hunk":"@@ -5971,129 +5941,82 @@ class PAL_NoHolder\n public:\n     void SuppressRelease() {}\n };\n+\n+struct PAL_SEHException\n+{\n+public:\n+    // Note that the following two are actually embedded in this heap-allocated\n+    // instance - in contrast to Win32, where the exception record would usually\n+    // be allocated on the stack.  This is needed because foreign cleanup handlers\n+    // partially unwind the stack on the second pass.\n+    EXCEPTION_POINTERS ExceptionPointers;\n+    EXCEPTION_RECORD ExceptionRecord;\n+    CONTEXT ContextRecord;\n+\n+    PAL_SEHException(EXCEPTION_RECORD *pExceptionRecord, CONTEXT *pContextRecord)\n+    {\n+        ExceptionPointers.ExceptionRecord = &ExceptionRecord;\n+        ExceptionPointers.ContextRecord = &ContextRecord;\n+        ExceptionRecord = *pExceptionRecord;\n+        ContextRecord = *pContextRecord;\n+    }\n+};\n+\n #endif // __cplusplus\n \n #define PAL_TRY(__ParamType, __paramDef, __paramRef)                            \\\n {                                                                               \\\n-    struct __HandlerData                                                        \\\n-    {                                                                           \\\n-        __ParamType __param;                                                    \\\n-        EXCEPTION_DISPOSITION __handlerDisposition;                             \\\n-        __HandlerData(__ParamType param) : __param(param) {}                    \\\n+    __ParamType __param = __paramRef;                                           \\\n+    auto tryBlock = [](__ParamType __paramDef)                                  \\\n+    {\n+\n+#define PAL_EXCEPT(dispositionExpression)                                       \\\n     };                                                                          \\\n-    __HandlerData __handlerData(__paramRef);                                    \\\n-    class __Body                                                                \\\n+    const bool isFinally = false;                                                     \\\n+    auto finallyBlock = []() {};                                                \\\n+    try                                                                         \\\n+    {                                                                           \\\n+        tryBlock(__param);                                                      \\\n+    }                                                                           \\\n+    catch (PAL_SEHException& ex)                                                \\\n     {                                                                           \\\n-    public:                                                                     \\\n-        static void Run(void *__pvHandlerData)\t\t\t\t\t                \\\n+        EXCEPTION_DISPOSITION disposition = dispositionExpression;              \\\n+        _ASSERTE(disposition != EXCEPTION_CONTINUE_EXECUTION);                  \\\n+        if (disposition == EXCEPTION_CONTINUE_SEARCH)                           \\\n         {                                                                       \\\n-            __ParamType __paramDef = ((__HandlerData *)__pvHandlerData)->__param;\t\\\n-            PAL_DUMMY_CALL;\n-\n-// On Windows 32bit, we dont invoke filters on the second pass.\n-// To ensure the same happens on the Mac, we check if we are \n-// in the first phase or not. If we are, we invoke the\n-// filter and save the disposition in a local static. \n-//\n-// However, if we are not in the first phase but in the second,\n-// and thus unwinding, then we return the disposition saved \n-// from the first pass back (similar to how CRT\n-// does it on x86).\n-#define PAL_EXCEPT(dispositionExpression)\t\t\t\t\\\n-        }                                                               \\\n-        static EXCEPTION_DISPOSITION Handler(\t\t\t\t\t\t\t\\\n-            EXCEPTION_POINTERS *ExceptionPointers,                      \\\n-            PAL_DISPATCHER_CONTEXT *DispatcherContext,                  \\\n-            void *pvHandlerData)\t\t\t\t\t\t\t\t\\\n-        {                                                               \\\n-            DEBUG_OK_TO_RETURN_BEGIN(PAL_EXCEPT)                        \\\n-            __HandlerData *pHandlerData = (__HandlerData *)pvHandlerData;                       \\\n-            void *pvParam = NULL;                                                               \\\n-            pvParam = pHandlerData->__param;                                                    \\\n-            if (!(ExceptionPointers->ExceptionRecord->ExceptionFlags & EXCEPTION_UNWINDING))\t\\\n-                pHandlerData->__handlerDisposition = (EXCEPTION_DISPOSITION) (dispositionExpression);\t\t\t\\\n-            return pHandlerData->__handlerDisposition;\t\t\t\t\t\t\\\n-            DEBUG_OK_TO_RETURN_END(PAL_EXCEPT)                          \\\n-        }                                                               \\\n-    };                                                                  \\\n-    BOOL __fExecuteHandler;                                             \\\n-    _Unwind_Exception *__exception =                                    \\\n-        PAL_TryExcept(__Body::Run, __Body::Handler, &__handlerData, &__fExecuteHandler);\t\\\n-    PAL_NoHolder __exceptionHolder;                                     \\\n-    if (__exception && __fExecuteHandler)                               \\\n-    {                                                                   \\\n-        PAL_CatchHolder __catchHolder(__exception);                     \\\n-        __exception = NULL;\n-\n-#define PAL_EXCEPT_FILTER(filter) PAL_EXCEPT(filter(ExceptionPointers, pvParam))\n+            throw;                                                              \\\n+        }\n \n-// Executes the handler if the specified exception code matches\n-// the one in the exception. Otherwise, returns EXCEPTION_CONTINUE_SEARCH.\n-#define PAL_EXCEPT_IF_EXCEPTION_CODE(dwExceptionCode) \\\n-        PAL_EXCEPT(((ExceptionPointers->ExceptionRecord->ExceptionCode == dwExceptionCode)?EXCEPTION_EXECUTE_HANDLER:EXCEPTION_CONTINUE_SEARCH))\n \n-#define PAL_FINALLY                                                     \\\n-        }                                                               \\\n-        static EXCEPTION_DISPOSITION Filter(                            \\\n-            EXCEPTION_POINTERS *ExceptionPointers,                      \\\n-            PAL_DISPATCHER_CONTEXT *DispatcherContext,                  \\\n-            void *pvHandlerData)                                        \\\n-        {                                                               \\\n-            DEBUG_OK_TO_RETURN_BEGIN(PAL_FINALLY)                       \\\n-            return EXCEPTION_CONTINUE_SEARCH;                           \\\n-            DEBUG_OK_TO_RETURN_END(PAL_FINALLY)                         \\\n-        }                                                               \\\n-    };                                                                  \\\n-    BOOL __fExecuteHandler;                                             \\\n-    _Unwind_Exception *__exception =                                    \\\n-        PAL_TryExcept(__Body::Run, __Body::Filter, &__handlerData, &__fExecuteHandler); \\\n-    PAL_ExceptionHolder __exceptionHolder(__exception);                 \\\n-    {\n-\n-#define PAL_ENDTRY                              \\\n-    }                                           \\\n-    if (__exception)                            \\\n-    {                                           \\\n-        __exceptionHolder.SuppressRelease();    \\\n-        PAL_Leave(PAL_BoundaryBottom);          \\\n-        _Unwind_Resume(__exception);            \\\n-    }                                           \\\n+#define PAL_EXCEPT_FILTER(filter) PAL_EXCEPT(filter(&ex.ExceptionPointers, __param))\n+\n+#define PAL_FINALLY \\\n+    }; \\\n+    const bool isFinally = true; \\\n+    auto finallyBlock = [&]() \\\n+    {                       \n+\n+#define PAL_ENDTRY \\\n+    }; \\\n+    if (isFinally) \\\n+    { \\\n+        try \\\n+        { \\\n+            tryBlock(__param);        \\","path":"src/pal/inc/pal.h","position":183,"original_position":183,"commit_id":"8eb59dba9ed6e7a46747bc0b3e75cc720dd536f0","original_commit_id":"8eb59dba9ed6e7a46747bc0b3e75cc720dd536f0","user":{"login":"jkotas","id":6668460,"avatar_url":"https://avatars.githubusercontent.com/u/6668460?v=3","gravatar_id":"","url":"https://api.github.com/users/jkotas","html_url":"https://github.com/jkotas","followers_url":"https://api.github.com/users/jkotas/followers","following_url":"https://api.github.com/users/jkotas/following{/other_user}","gists_url":"https://api.github.com/users/jkotas/gists{/gist_id}","starred_url":"https://api.github.com/users/jkotas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkotas/subscriptions","organizations_url":"https://api.github.com/users/jkotas/orgs","repos_url":"https://api.github.com/users/jkotas/repos","events_url":"https://api.github.com/users/jkotas/events{/privacy}","received_events_url":"https://api.github.com/users/jkotas/received_events","type":"User","site_admin":false},"body":"Cosmetic - extra spaces between ; and \\","created_at":"2015-02-20T13:27:55Z","updated_at":"2015-02-20T13:27:55Z","html_url":"https://github.com/dotnet/coreclr/pull/308#discussion_r25069096","pull_request_url":"https://api.github.com/repos/dotnet/coreclr/pulls/308","_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/25069096"},"html":{"href":"https://github.com/dotnet/coreclr/pull/308#discussion_r25069096"},"pull_request":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/308"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/308","id":29693190,"html_url":"https://github.com/dotnet/coreclr/pull/308","diff_url":"https://github.com/dotnet/coreclr/pull/308.diff","patch_url":"https://github.com/dotnet/coreclr/pull/308.patch","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/308","number":308,"state":"open","locked":false,"title":"Reimplement native exception handling for PAL","user":{"login":"janvorli","id":10758568,"avatar_url":"https://avatars.githubusercontent.com/u/10758568?v=3","gravatar_id":"","url":"https://api.github.com/users/janvorli","html_url":"https://github.com/janvorli","followers_url":"https://api.github.com/users/janvorli/followers","following_url":"https://api.github.com/users/janvorli/following{/other_user}","gists_url":"https://api.github.com/users/janvorli/gists{/gist_id}","starred_url":"https://api.github.com/users/janvorli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janvorli/subscriptions","organizations_url":"https://api.github.com/users/janvorli/orgs","repos_url":"https://api.github.com/users/janvorli/repos","events_url":"https://api.github.com/users/janvorli/events{/privacy}","received_events_url":"https://api.github.com/users/janvorli/received_events","type":"User","site_admin":false},"body":"This change removes the preexisting exception handling in PAL that was simulating Windows\r\nSEH using a lot of low level machinery. The only remaining part is the code that raises\r\nthe exception and that extracts the exception context information.\r\nThe PAL_TRY, PAL_EXCEPT, PAL_FINALLY, ... macros are reimplemented using plain C++ exception\r\nhandling.","created_at":"2015-02-20T12:47:13Z","updated_at":"2015-02-20T13:27:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15528af00ece04dba90cc2829cf43f5107fea218","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/coreclr/pulls/308/commits","review_comments_url":"https://api.github.com/repos/dotnet/coreclr/pulls/308/comments","review_comment_url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/{number}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/308/comments","statuses_url":"https://api.github.com/repos/dotnet/coreclr/statuses/8eb59dba9ed6e7a46747bc0b3e75cc720dd536f0","head":{"label":"janvorli:exception-handling","ref":"exception-handling","sha":"8eb59dba9ed6e7a46747bc0b3e75cc720dd536f0","user":{"login":"janvorli","id":10758568,"avatar_url":"https://avatars.githubusercontent.com/u/10758568?v=3","gravatar_id":"","url":"https://api.github.com/users/janvorli","html_url":"https://github.com/janvorli","followers_url":"https://api.github.com/users/janvorli/followers","following_url":"https://api.github.com/users/janvorli/following{/other_user}","gists_url":"https://api.github.com/users/janvorli/gists{/gist_id}","starred_url":"https://api.github.com/users/janvorli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janvorli/subscriptions","organizations_url":"https://api.github.com/users/janvorli/orgs","repos_url":"https://api.github.com/users/janvorli/repos","events_url":"https://api.github.com/users/janvorli/events{/privacy}","received_events_url":"https://api.github.com/users/janvorli/received_events","type":"User","site_admin":false},"repo":{"id":30583176,"name":"coreclr","full_name":"janvorli/coreclr","owner":{"login":"janvorli","id":10758568,"avatar_url":"https://avatars.githubusercontent.com/u/10758568?v=3","gravatar_id":"","url":"https://api.github.com/users/janvorli","html_url":"https://github.com/janvorli","followers_url":"https://api.github.com/users/janvorli/followers","following_url":"https://api.github.com/users/janvorli/following{/other_user}","gists_url":"https://api.github.com/users/janvorli/gists{/gist_id}","starred_url":"https://api.github.com/users/janvorli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janvorli/subscriptions","organizations_url":"https://api.github.com/users/janvorli/orgs","repos_url":"https://api.github.com/users/janvorli/repos","events_url":"https://api.github.com/users/janvorli/events{/privacy}","received_events_url":"https://api.github.com/users/janvorli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/janvorli/coreclr","description":"This repo contains the .NET Core runtime, called CoreCLR. It is an execution engine for .NET apps, performing functions such as IL byte code loading, compilation to machine code and garbage collection. The repo contains the complete up-to-date CoreCLR codebase.","fork":true,"url":"https://api.github.com/repos/janvorli/coreclr","forks_url":"https://api.github.com/repos/janvorli/coreclr/forks","keys_url":"https://api.github.com/repos/janvorli/coreclr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/janvorli/coreclr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/janvorli/coreclr/teams","hooks_url":"https://api.github.com/repos/janvorli/coreclr/hooks","issue_events_url":"https://api.github.com/repos/janvorli/coreclr/issues/events{/number}","events_url":"https://api.github.com/repos/janvorli/coreclr/events","assignees_url":"https://api.github.com/repos/janvorli/coreclr/assignees{/user}","branches_url":"https://api.github.com/repos/janvorli/coreclr/branches{/branch}","tags_url":"https://api.github.com/repos/janvorli/coreclr/tags","blobs_url":"https://api.github.com/repos/janvorli/coreclr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/janvorli/coreclr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/janvorli/coreclr/git/refs{/sha}","trees_url":"https://api.github.com/repos/janvorli/coreclr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/janvorli/coreclr/statuses/{sha}","languages_url":"https://api.github.com/repos/janvorli/coreclr/languages","stargazers_url":"https://api.github.com/repos/janvorli/coreclr/stargazers","contributors_url":"https://api.github.com/repos/janvorli/coreclr/contributors","subscribers_url":"https://api.github.com/repos/janvorli/coreclr/subscribers","subscription_url":"https://api.github.com/repos/janvorli/coreclr/subscription","commits_url":"https://api.github.com/repos/janvorli/coreclr/commits{/sha}","git_commits_url":"https://api.github.com/repos/janvorli/coreclr/git/commits{/sha}","comments_url":"https://api.github.com/repos/janvorli/coreclr/comments{/number}","issue_comment_url":"https://api.github.com/repos/janvorli/coreclr/issues/comments/{number}","contents_url":"https://api.github.com/repos/janvorli/coreclr/contents/{+path}","compare_url":"https://api.github.com/repos/janvorli/coreclr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/janvorli/coreclr/merges","archive_url":"https://api.github.com/repos/janvorli/coreclr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/janvorli/coreclr/downloads","issues_url":"https://api.github.com/repos/janvorli/coreclr/issues{/number}","pulls_url":"https://api.github.com/repos/janvorli/coreclr/pulls{/number}","milestones_url":"https://api.github.com/repos/janvorli/coreclr/milestones{/number}","notifications_url":"https://api.github.com/repos/janvorli/coreclr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/janvorli/coreclr/labels{/name}","releases_url":"https://api.github.com/repos/janvorli/coreclr/releases{/id}","created_at":"2015-02-10T08:49:34Z","updated_at":"2015-02-10T08:49:57Z","pushed_at":"2015-02-20T12:44:35Z","git_url":"git://github.com/janvorli/coreclr.git","ssh_url":"git@github.com:janvorli/coreclr.git","clone_url":"https://github.com/janvorli/coreclr.git","svn_url":"https://github.com/janvorli/coreclr","homepage":"","size":25045,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"44fb223c6240d303363dfa9003b17bc7cac753bc","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":30092893,"name":"coreclr","full_name":"dotnet/coreclr","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/coreclr","description":"This repo contains the .NET Core runtime, called CoreCLR. It is an execution engine for .NET apps, performing functions such as IL byte code loading, compilation to machine code and garbage collection. The repo contains the complete up-to-date CoreCLR codebase.","fork":false,"url":"https://api.github.com/repos/dotnet/coreclr","forks_url":"https://api.github.com/repos/dotnet/coreclr/forks","keys_url":"https://api.github.com/repos/dotnet/coreclr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/coreclr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/coreclr/teams","hooks_url":"https://api.github.com/repos/dotnet/coreclr/hooks","issue_events_url":"https://api.github.com/repos/dotnet/coreclr/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/coreclr/events","assignees_url":"https://api.github.com/repos/dotnet/coreclr/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/coreclr/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/coreclr/tags","blobs_url":"https://api.github.com/repos/dotnet/coreclr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/coreclr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/coreclr/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/coreclr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/coreclr/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/coreclr/languages","stargazers_url":"https://api.github.com/repos/dotnet/coreclr/stargazers","contributors_url":"https://api.github.com/repos/dotnet/coreclr/contributors","subscribers_url":"https://api.github.com/repos/dotnet/coreclr/subscribers","subscription_url":"https://api.github.com/repos/dotnet/coreclr/subscription","commits_url":"https://api.github.com/repos/dotnet/coreclr/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/coreclr/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/coreclr/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/coreclr/issues/comments/{number}","contents_url":"https://api.github.com/repos/dotnet/coreclr/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/coreclr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/coreclr/merges","archive_url":"https://api.github.com/repos/dotnet/coreclr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/coreclr/downloads","issues_url":"https://api.github.com/repos/dotnet/coreclr/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/coreclr/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/coreclr/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/coreclr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/coreclr/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/coreclr/releases{/id}","created_at":"2015-01-30T22:10:02Z","updated_at":"2015-02-20T09:04:35Z","pushed_at":"2015-02-20T03:12:06Z","git_url":"git://github.com/dotnet/coreclr.git","ssh_url":"git@github.com:dotnet/coreclr.git","clone_url":"https://github.com/dotnet/coreclr.git","svn_url":"https://github.com/dotnet/coreclr","homepage":"","size":29567,"stargazers_count":3631,"watchers_count":3631,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":570,"mirror_url":null,"open_issues_count":71,"forks":570,"open_issues":71,"watchers":3631,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/308"},"html":{"href":"https://github.com/dotnet/coreclr/pull/308"},"issue":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/308"},"comments":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/308/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/308/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/308/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/coreclr/statuses/8eb59dba9ed6e7a46747bc0b3e75cc720dd536f0"}}}}