{"action":"created","comment":{"url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/comments/51835752","id":51835752,"diff_hunk":"@@ -33,38 +48,86 @@ - (instancetype)init {\n     if (self) {\n         // Create a hash table of weak pointers to mixpanel instances\n         _mixpanelInstances = [NSHashTable weakObjectsHashTable];\n-        \n         // Save the existing exception handler\n         _defaultExceptionHandler = NSGetUncaughtExceptionHandler();\n         // Install our handler\n         NSSetUncaughtExceptionHandler(&mp_handleUncaughtException);\n+        // Install signal Handler\n+        registerFatalSignals();\n     }\n     return self;\n }\n \n - (void)addMixpanelInstance:(Mixpanel *)instance {\n     NSParameterAssert(instance != nil);\n-    \n     [self.mixpanelInstances addObject:instance];\n }\n \n static void mp_handleUncaughtException(NSException *exception) {\n     MixpanelExceptionHandler *handler = [MixpanelExceptionHandler sharedHandler];\n-    \n-    // Archive the values for each Mixpanel instance\n-    for (Mixpanel *instance in handler.mixpanelInstances) {\n-        // Since we're storing the instances in a weak table, we need to ensure the pointer hasn't become nil\n-        if (instance) {\n-            [instance archive];\n+    NSLog(@\"!!!!!!\");\n+    if(isAlreadyExceptionOccured==0) {\n+        OSAtomicOr32Barrier(1, &isAlreadyExceptionOccured);\n+        // Archive the values for each Mixpanel instance\n+        for (Mixpanel *instance in handler.mixpanelInstances) {\n+            // Since we're storing the instances in a weak table, we need to ensure the pointer hasn't become nil\n+            if (instance) {\n+                [instance archive];\n+            }\n         }\n+        \n+        MixpanelError(@\"Encountered an uncaught exception. All Mixpanel instances were archived.\");\n     }\n-    \n-    MixpanelError(@\"Encountered an uncaught exception. All Mixpanel instances were archived.\");\n-    \n     if (handler.defaultExceptionHandler) {\n         // Ensure the existing handler gets called once we're finished\n         handler.defaultExceptionHandler(exception);\n     }\n }\n \n+static void mp_handleSignal(int sig, siginfo_t *info, void *context) {\n+    unregisterFatalSignals();\n+    MixpanelError(@\"We received a signal: %d\", sig);\n+    NSLog(@\"??????\");\n+\n+    NSException* exception = [NSException\n+                              exceptionWithName:@\"UncaughtException\"\n+                              reason:\n+                              [NSString stringWithFormat:\n+                               NSLocalizedString(@\"Signal %d was raised.\", nil),\n+                               sig]\n+                              userInfo:\n+                              [NSDictionary\n+                               dictionaryWithObject:[NSNumber numberWithInt:sig]\n+                               forKey:@\"UncaughtExceptionSignalKey\"]];\n+    \n+    mp_handleUncaughtException(exception);\n+}\n+\n+static void registerFatalSignals() {\n+    struct sigaction sa;\n+    /* Configure action */\n+    memset(&sa, 0, sizeof(sa));\n+    sa.sa_flags =  SA_SIGINFO | SA_ONSTACK;\n+    sa.sa_sigaction = &mp_handleSignal;\n+    sigemptyset(&sa.sa_mask);\n+    /* Set new sigaction */\n+    for (int i =0 ;i<n_fatal_signals; i++) {","path":"Mixpanel/MixpanelExceptionHandler.m","position":107,"original_position":107,"commit_id":"4456c1adbd047d712e1725272240396b70a7920c","original_commit_id":"4456c1adbd047d712e1725272240396b70a7920c","user":{"login":"samgreen","id":276118,"avatar_url":"https://avatars.githubusercontent.com/u/276118?v=3","gravatar_id":"","url":"https://api.github.com/users/samgreen","html_url":"https://github.com/samgreen","followers_url":"https://api.github.com/users/samgreen/followers","following_url":"https://api.github.com/users/samgreen/following{/other_user}","gists_url":"https://api.github.com/users/samgreen/gists{/gist_id}","starred_url":"https://api.github.com/users/samgreen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samgreen/subscriptions","organizations_url":"https://api.github.com/users/samgreen/orgs","repos_url":"https://api.github.com/users/samgreen/repos","events_url":"https://api.github.com/users/samgreen/events{/privacy}","received_events_url":"https://api.github.com/users/samgreen/received_events","type":"User","site_admin":false},"body":"Spacing here. Should be: \r\n\r\n`for (int i =0 ;  i< n_fatal_signals; i++) {`","created_at":"2016-02-04T06:54:40Z","updated_at":"2016-02-04T06:54:40Z","html_url":"https://github.com/mixpanel/mixpanel-iphone/pull/430#discussion_r51835752","pull_request_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/430","_links":{"self":{"href":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/comments/51835752"},"html":{"href":"https://github.com/mixpanel/mixpanel-iphone/pull/430#discussion_r51835752"},"pull_request":{"href":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/430"}}},"pull_request":{"url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/430","id":58244811,"html_url":"https://github.com/mixpanel/mixpanel-iphone/pull/430","diff_url":"https://github.com/mixpanel/mixpanel-iphone/pull/430.diff","patch_url":"https://github.com/mixpanel/mixpanel-iphone/pull/430.patch","issue_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/issues/430","number":430,"state":"open","locked":false,"title":"Added signalHandler to Mixpanel ","user":{"login":"uzysjung","id":1260081,"avatar_url":"https://avatars.githubusercontent.com/u/1260081?v=3","gravatar_id":"","url":"https://api.github.com/users/uzysjung","html_url":"https://github.com/uzysjung","followers_url":"https://api.github.com/users/uzysjung/followers","following_url":"https://api.github.com/users/uzysjung/following{/other_user}","gists_url":"https://api.github.com/users/uzysjung/gists{/gist_id}","starred_url":"https://api.github.com/users/uzysjung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uzysjung/subscriptions","organizations_url":"https://api.github.com/users/uzysjung/orgs","repos_url":"https://api.github.com/users/uzysjung/repos","events_url":"https://api.github.com/users/uzysjung/events{/privacy}","received_events_url":"https://api.github.com/users/uzysjung/received_events","type":"User","site_admin":false},"body":"UncaughtExceptionHandler can not catch specific crash such as segmantation fault, floating point exception, bus error, etc.\r\n\r\nIn order to prevent to lose data from this crash, use signalHandler.\r\n\r\nI added SignalHandler.\r\nIt prevent to lose data when app is crashed.\r\n\r\nThanks.","created_at":"2016-02-04T06:00:57Z","updated_at":"2016-02-04T06:54:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"866ac4f7921a9fb8e78cafdf173dae389efebbcd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/430/commits","review_comments_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/430/comments","review_comment_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/issues/430/comments","statuses_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/statuses/4456c1adbd047d712e1725272240396b70a7920c","head":{"label":"uzysjung:master","ref":"master","sha":"4456c1adbd047d712e1725272240396b70a7920c","user":{"login":"uzysjung","id":1260081,"avatar_url":"https://avatars.githubusercontent.com/u/1260081?v=3","gravatar_id":"","url":"https://api.github.com/users/uzysjung","html_url":"https://github.com/uzysjung","followers_url":"https://api.github.com/users/uzysjung/followers","following_url":"https://api.github.com/users/uzysjung/following{/other_user}","gists_url":"https://api.github.com/users/uzysjung/gists{/gist_id}","starred_url":"https://api.github.com/users/uzysjung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uzysjung/subscriptions","organizations_url":"https://api.github.com/users/uzysjung/orgs","repos_url":"https://api.github.com/users/uzysjung/repos","events_url":"https://api.github.com/users/uzysjung/events{/privacy}","received_events_url":"https://api.github.com/users/uzysjung/received_events","type":"User","site_admin":false},"repo":{"id":51053466,"name":"mixpanel-iphone","full_name":"uzysjung/mixpanel-iphone","owner":{"login":"uzysjung","id":1260081,"avatar_url":"https://avatars.githubusercontent.com/u/1260081?v=3","gravatar_id":"","url":"https://api.github.com/users/uzysjung","html_url":"https://github.com/uzysjung","followers_url":"https://api.github.com/users/uzysjung/followers","following_url":"https://api.github.com/users/uzysjung/following{/other_user}","gists_url":"https://api.github.com/users/uzysjung/gists{/gist_id}","starred_url":"https://api.github.com/users/uzysjung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uzysjung/subscriptions","organizations_url":"https://api.github.com/users/uzysjung/orgs","repos_url":"https://api.github.com/users/uzysjung/repos","events_url":"https://api.github.com/users/uzysjung/events{/privacy}","received_events_url":"https://api.github.com/users/uzysjung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/uzysjung/mixpanel-iphone","description":"iPhone tracking library for Mixpanel Analytics","fork":true,"url":"https://api.github.com/repos/uzysjung/mixpanel-iphone","forks_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/forks","keys_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/teams","hooks_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/hooks","issue_events_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/issues/events{/number}","events_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/events","assignees_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/assignees{/user}","branches_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/branches{/branch}","tags_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/tags","blobs_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/git/refs{/sha}","trees_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/statuses/{sha}","languages_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/languages","stargazers_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/stargazers","contributors_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/contributors","subscribers_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/subscribers","subscription_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/subscription","commits_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/commits{/sha}","git_commits_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/git/commits{/sha}","comments_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/comments{/number}","issue_comment_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/issues/comments{/number}","contents_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/contents/{+path}","compare_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/merges","archive_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/downloads","issues_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/issues{/number}","pulls_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/pulls{/number}","milestones_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/milestones{/number}","notifications_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/labels{/name}","releases_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/releases{/id}","deployments_url":"https://api.github.com/repos/uzysjung/mixpanel-iphone/deployments","created_at":"2016-02-04T05:07:15Z","updated_at":"2016-02-04T05:07:16Z","pushed_at":"2016-02-04T05:54:43Z","git_url":"git://github.com/uzysjung/mixpanel-iphone.git","ssh_url":"git@github.com:uzysjung/mixpanel-iphone.git","clone_url":"https://github.com/uzysjung/mixpanel-iphone.git","svn_url":"https://github.com/uzysjung/mixpanel-iphone","homepage":"http://mixpanel.com","size":4618,"stargazers_count":0,"watchers_count":0,"language":"Objective-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":"mixpanel:master","ref":"master","sha":"dd8e82d3548097b06bc28b964c2b6152c32d1e07","user":{"login":"mixpanel","id":63653,"avatar_url":"https://avatars.githubusercontent.com/u/63653?v=3","gravatar_id":"","url":"https://api.github.com/users/mixpanel","html_url":"https://github.com/mixpanel","followers_url":"https://api.github.com/users/mixpanel/followers","following_url":"https://api.github.com/users/mixpanel/following{/other_user}","gists_url":"https://api.github.com/users/mixpanel/gists{/gist_id}","starred_url":"https://api.github.com/users/mixpanel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mixpanel/subscriptions","organizations_url":"https://api.github.com/users/mixpanel/orgs","repos_url":"https://api.github.com/users/mixpanel/repos","events_url":"https://api.github.com/users/mixpanel/events{/privacy}","received_events_url":"https://api.github.com/users/mixpanel/received_events","type":"Organization","site_admin":false},"repo":{"id":775069,"name":"mixpanel-iphone","full_name":"mixpanel/mixpanel-iphone","owner":{"login":"mixpanel","id":63653,"avatar_url":"https://avatars.githubusercontent.com/u/63653?v=3","gravatar_id":"","url":"https://api.github.com/users/mixpanel","html_url":"https://github.com/mixpanel","followers_url":"https://api.github.com/users/mixpanel/followers","following_url":"https://api.github.com/users/mixpanel/following{/other_user}","gists_url":"https://api.github.com/users/mixpanel/gists{/gist_id}","starred_url":"https://api.github.com/users/mixpanel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mixpanel/subscriptions","organizations_url":"https://api.github.com/users/mixpanel/orgs","repos_url":"https://api.github.com/users/mixpanel/repos","events_url":"https://api.github.com/users/mixpanel/events{/privacy}","received_events_url":"https://api.github.com/users/mixpanel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mixpanel/mixpanel-iphone","description":"iPhone tracking library for Mixpanel Analytics","fork":false,"url":"https://api.github.com/repos/mixpanel/mixpanel-iphone","forks_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/forks","keys_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/teams","hooks_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/hooks","issue_events_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/issues/events{/number}","events_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/events","assignees_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/assignees{/user}","branches_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/branches{/branch}","tags_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/tags","blobs_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/git/refs{/sha}","trees_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/statuses/{sha}","languages_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/languages","stargazers_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/stargazers","contributors_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/contributors","subscribers_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/subscribers","subscription_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/subscription","commits_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/commits{/sha}","git_commits_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/git/commits{/sha}","comments_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/comments{/number}","issue_comment_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/issues/comments{/number}","contents_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/contents/{+path}","compare_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/merges","archive_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/downloads","issues_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/issues{/number}","pulls_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls{/number}","milestones_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/milestones{/number}","notifications_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/labels{/name}","releases_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/releases{/id}","deployments_url":"https://api.github.com/repos/mixpanel/mixpanel-iphone/deployments","created_at":"2010-07-14T17:48:47Z","updated_at":"2016-01-29T14:24:33Z","pushed_at":"2016-02-04T06:00:57Z","git_url":"git://github.com/mixpanel/mixpanel-iphone.git","ssh_url":"git@github.com:mixpanel/mixpanel-iphone.git","clone_url":"https://github.com/mixpanel/mixpanel-iphone.git","svn_url":"https://github.com/mixpanel/mixpanel-iphone","homepage":"http://mixpanel.com","size":6939,"stargazers_count":416,"watchers_count":416,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":322,"mirror_url":null,"open_issues_count":29,"forks":322,"open_issues":29,"watchers":416,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/430"},"html":{"href":"https://github.com/mixpanel/mixpanel-iphone/pull/430"},"issue":{"href":"https://api.github.com/repos/mixpanel/mixpanel-iphone/issues/430"},"comments":{"href":"https://api.github.com/repos/mixpanel/mixpanel-iphone/issues/430/comments"},"review_comments":{"href":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/430/comments"},"review_comment":{"href":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mixpanel/mixpanel-iphone/pulls/430/commits"},"statuses":{"href":"https://api.github.com/repos/mixpanel/mixpanel-iphone/statuses/4456c1adbd047d712e1725272240396b70a7920c"}}}}