{"action":"created","comment":{"url":"https://api.github.com/repos/libuv/libuv/pulls/comments/59418369","id":59418369,"diff_hunk":"@@ -0,0 +1,111 @@\n+/*\n+Copyright (c) 2016, Kari Tristan Helgason <kthelgason@gmail.com>\n+\n+Permission to use, copy, modify, and/or distribute this software for any\n+purpose with or without fee is hereby granted, provided that the above\n+copyright notice and this permission notice appear in all copies.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n+*/\n+\n+#include <stdlib.h>\n+#include \"pthread-barrier.h\"\n+\n+/* TODO: support barrier_attr */\n+int pthread_barrier_init(pthread_barrier_t* barrier,\n+                         const void* barrier_attr,\n+                         unsigned count) {\n+  int rc;\n+  _barrier* b;\n+\n+  if (barrier == NULL || count == 0)\n+    return EINVAL;\n+\n+  barrier->b = (_barrier*)malloc(sizeof(_barrier));","path":"src/unix/pthread-barrier.c","position":30,"original_position":30,"commit_id":"2d22f4e5aa8ce3c8a7a1c62157d08fc2a6a7ed72","original_commit_id":"2d22f4e5aa8ce3c8a7a1c62157d08fc2a6a7ed72","user":{"login":"bnoordhuis","id":275871,"avatar_url":"https://avatars.githubusercontent.com/u/275871?v=3","gravatar_id":"","url":"https://api.github.com/users/bnoordhuis","html_url":"https://github.com/bnoordhuis","followers_url":"https://api.github.com/users/bnoordhuis/followers","following_url":"https://api.github.com/users/bnoordhuis/following{/other_user}","gists_url":"https://api.github.com/users/bnoordhuis/gists{/gist_id}","starred_url":"https://api.github.com/users/bnoordhuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnoordhuis/subscriptions","organizations_url":"https://api.github.com/users/bnoordhuis/orgs","repos_url":"https://api.github.com/users/bnoordhuis/repos","events_url":"https://api.github.com/users/bnoordhuis/events{/privacy}","received_events_url":"https://api.github.com/users/bnoordhuis/received_events","type":"User","site_admin":false},"body":"Superfluous cast.  Also, I'd write it as `malloc(sizeof(*barrier->b))`.  Ideally, don't touch `barrier->b` until the end of the function.","created_at":"2016-04-12T17:34:04Z","updated_at":"2016-04-12T17:34:05Z","html_url":"https://github.com/libuv/libuv/pull/790#discussion_r59418369","pull_request_url":"https://api.github.com/repos/libuv/libuv/pulls/790","_links":{"self":{"href":"https://api.github.com/repos/libuv/libuv/pulls/comments/59418369"},"html":{"href":"https://github.com/libuv/libuv/pull/790#discussion_r59418369"},"pull_request":{"href":"https://api.github.com/repos/libuv/libuv/pulls/790"}}},"pull_request":{"url":"https://api.github.com/repos/libuv/libuv/pulls/790","id":64336612,"html_url":"https://github.com/libuv/libuv/pull/790","diff_url":"https://github.com/libuv/libuv/pull/790.diff","patch_url":"https://github.com/libuv/libuv/pull/790.patch","issue_url":"https://api.github.com/repos/libuv/libuv/issues/790","number":790,"state":"open","locked":false,"title":"unix: fix bug in android barrier implementation","user":{"login":"kthelgason","id":2563784,"avatar_url":"https://avatars.githubusercontent.com/u/2563784?v=3","gravatar_id":"","url":"https://api.github.com/users/kthelgason","html_url":"https://github.com/kthelgason","followers_url":"https://api.github.com/users/kthelgason/followers","following_url":"https://api.github.com/users/kthelgason/following{/other_user}","gists_url":"https://api.github.com/users/kthelgason/gists{/gist_id}","starred_url":"https://api.github.com/users/kthelgason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kthelgason/subscriptions","organizations_url":"https://api.github.com/users/kthelgason/orgs","repos_url":"https://api.github.com/users/kthelgason/repos","events_url":"https://api.github.com/users/kthelgason/events{/privacy}","received_events_url":"https://api.github.com/users/kthelgason/received_events","type":"User","site_admin":false},"body":"There was a memory corruption issue with the pthread barrier\r\nimplementation on android, where a barrier could still be in use by one\r\nthread when being freed by another. This fixes that issue and adds lots\r\nof missing error handling/signaling.\r\n\r\nThis adds a new implementation of pthread_barrier heavily based on the one\r\nfrom [openBSD](https://github.com/openbsd-unofficial/openbsd-src/blob/848c0e150cb26564eb40b4250c58f49e34f33a05/lib/librthread/rthread_barrier.c) but with a fix added for the memory corruption issue. This new implementation is used in place of the fallback implementation on Darwin and Android, so there is now one unified implementation instead of two separate ones. This also cleans up the code in `/src/unix/thread.c` a bit and removes some `ifdef`s.\r\n\r\nI've built and tested this code on OS X and all the tests pass, and I've also built it for android, and that works, though I have not run the tests there. There are some tests for the barrier stuff but they're not very extensive. Perhaps I can add some more thorough tests if you want.\r\n\r\nIssue: #615 ","created_at":"2016-03-28T15:55:46Z","updated_at":"2016-04-12T17:34:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2bcf5a6d0ad37770adf625456606b7863b56b99c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/libuv/libuv/pulls/790/commits","review_comments_url":"https://api.github.com/repos/libuv/libuv/pulls/790/comments","review_comment_url":"https://api.github.com/repos/libuv/libuv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libuv/libuv/issues/790/comments","statuses_url":"https://api.github.com/repos/libuv/libuv/statuses/2d22f4e5aa8ce3c8a7a1c62157d08fc2a6a7ed72","head":{"label":"kthelgason:pthread-barrier-1","ref":"pthread-barrier-1","sha":"2d22f4e5aa8ce3c8a7a1c62157d08fc2a6a7ed72","user":{"login":"kthelgason","id":2563784,"avatar_url":"https://avatars.githubusercontent.com/u/2563784?v=3","gravatar_id":"","url":"https://api.github.com/users/kthelgason","html_url":"https://github.com/kthelgason","followers_url":"https://api.github.com/users/kthelgason/followers","following_url":"https://api.github.com/users/kthelgason/following{/other_user}","gists_url":"https://api.github.com/users/kthelgason/gists{/gist_id}","starred_url":"https://api.github.com/users/kthelgason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kthelgason/subscriptions","organizations_url":"https://api.github.com/users/kthelgason/orgs","repos_url":"https://api.github.com/users/kthelgason/repos","events_url":"https://api.github.com/users/kthelgason/events{/privacy}","received_events_url":"https://api.github.com/users/kthelgason/received_events","type":"User","site_admin":false},"repo":{"id":52915617,"name":"libuv","full_name":"kthelgason/libuv","owner":{"login":"kthelgason","id":2563784,"avatar_url":"https://avatars.githubusercontent.com/u/2563784?v=3","gravatar_id":"","url":"https://api.github.com/users/kthelgason","html_url":"https://github.com/kthelgason","followers_url":"https://api.github.com/users/kthelgason/followers","following_url":"https://api.github.com/users/kthelgason/following{/other_user}","gists_url":"https://api.github.com/users/kthelgason/gists{/gist_id}","starred_url":"https://api.github.com/users/kthelgason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kthelgason/subscriptions","organizations_url":"https://api.github.com/users/kthelgason/orgs","repos_url":"https://api.github.com/users/kthelgason/repos","events_url":"https://api.github.com/users/kthelgason/events{/privacy}","received_events_url":"https://api.github.com/users/kthelgason/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kthelgason/libuv","description":"Cross-platform asynchronous I/O","fork":true,"url":"https://api.github.com/repos/kthelgason/libuv","forks_url":"https://api.github.com/repos/kthelgason/libuv/forks","keys_url":"https://api.github.com/repos/kthelgason/libuv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kthelgason/libuv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kthelgason/libuv/teams","hooks_url":"https://api.github.com/repos/kthelgason/libuv/hooks","issue_events_url":"https://api.github.com/repos/kthelgason/libuv/issues/events{/number}","events_url":"https://api.github.com/repos/kthelgason/libuv/events","assignees_url":"https://api.github.com/repos/kthelgason/libuv/assignees{/user}","branches_url":"https://api.github.com/repos/kthelgason/libuv/branches{/branch}","tags_url":"https://api.github.com/repos/kthelgason/libuv/tags","blobs_url":"https://api.github.com/repos/kthelgason/libuv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kthelgason/libuv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kthelgason/libuv/git/refs{/sha}","trees_url":"https://api.github.com/repos/kthelgason/libuv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kthelgason/libuv/statuses/{sha}","languages_url":"https://api.github.com/repos/kthelgason/libuv/languages","stargazers_url":"https://api.github.com/repos/kthelgason/libuv/stargazers","contributors_url":"https://api.github.com/repos/kthelgason/libuv/contributors","subscribers_url":"https://api.github.com/repos/kthelgason/libuv/subscribers","subscription_url":"https://api.github.com/repos/kthelgason/libuv/subscription","commits_url":"https://api.github.com/repos/kthelgason/libuv/commits{/sha}","git_commits_url":"https://api.github.com/repos/kthelgason/libuv/git/commits{/sha}","comments_url":"https://api.github.com/repos/kthelgason/libuv/comments{/number}","issue_comment_url":"https://api.github.com/repos/kthelgason/libuv/issues/comments{/number}","contents_url":"https://api.github.com/repos/kthelgason/libuv/contents/{+path}","compare_url":"https://api.github.com/repos/kthelgason/libuv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kthelgason/libuv/merges","archive_url":"https://api.github.com/repos/kthelgason/libuv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kthelgason/libuv/downloads","issues_url":"https://api.github.com/repos/kthelgason/libuv/issues{/number}","pulls_url":"https://api.github.com/repos/kthelgason/libuv/pulls{/number}","milestones_url":"https://api.github.com/repos/kthelgason/libuv/milestones{/number}","notifications_url":"https://api.github.com/repos/kthelgason/libuv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kthelgason/libuv/labels{/name}","releases_url":"https://api.github.com/repos/kthelgason/libuv/releases{/id}","deployments_url":"https://api.github.com/repos/kthelgason/libuv/deployments","created_at":"2016-03-01T22:40:03Z","updated_at":"2016-03-01T22:40:05Z","pushed_at":"2016-04-12T17:03:27Z","git_url":"git://github.com/kthelgason/libuv.git","ssh_url":"git@github.com:kthelgason/libuv.git","clone_url":"https://github.com/kthelgason/libuv.git","svn_url":"https://github.com/kthelgason/libuv","homepage":"http://libuv.org/","size":10669,"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":"v1.x"}},"base":{"label":"libuv:v1.x","ref":"v1.x","sha":"be8e237a8e462f8517392eccf0f94a30d16d7ef3","user":{"login":"libuv","id":4030929,"avatar_url":"https://avatars.githubusercontent.com/u/4030929?v=3","gravatar_id":"","url":"https://api.github.com/users/libuv","html_url":"https://github.com/libuv","followers_url":"https://api.github.com/users/libuv/followers","following_url":"https://api.github.com/users/libuv/following{/other_user}","gists_url":"https://api.github.com/users/libuv/gists{/gist_id}","starred_url":"https://api.github.com/users/libuv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libuv/subscriptions","organizations_url":"https://api.github.com/users/libuv/orgs","repos_url":"https://api.github.com/users/libuv/repos","events_url":"https://api.github.com/users/libuv/events{/privacy}","received_events_url":"https://api.github.com/users/libuv/received_events","type":"Organization","site_admin":false},"repo":{"id":14812739,"name":"libuv","full_name":"libuv/libuv","owner":{"login":"libuv","id":4030929,"avatar_url":"https://avatars.githubusercontent.com/u/4030929?v=3","gravatar_id":"","url":"https://api.github.com/users/libuv","html_url":"https://github.com/libuv","followers_url":"https://api.github.com/users/libuv/followers","following_url":"https://api.github.com/users/libuv/following{/other_user}","gists_url":"https://api.github.com/users/libuv/gists{/gist_id}","starred_url":"https://api.github.com/users/libuv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libuv/subscriptions","organizations_url":"https://api.github.com/users/libuv/orgs","repos_url":"https://api.github.com/users/libuv/repos","events_url":"https://api.github.com/users/libuv/events{/privacy}","received_events_url":"https://api.github.com/users/libuv/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/libuv/libuv","description":"Cross-platform asynchronous I/O","fork":false,"url":"https://api.github.com/repos/libuv/libuv","forks_url":"https://api.github.com/repos/libuv/libuv/forks","keys_url":"https://api.github.com/repos/libuv/libuv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libuv/libuv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libuv/libuv/teams","hooks_url":"https://api.github.com/repos/libuv/libuv/hooks","issue_events_url":"https://api.github.com/repos/libuv/libuv/issues/events{/number}","events_url":"https://api.github.com/repos/libuv/libuv/events","assignees_url":"https://api.github.com/repos/libuv/libuv/assignees{/user}","branches_url":"https://api.github.com/repos/libuv/libuv/branches{/branch}","tags_url":"https://api.github.com/repos/libuv/libuv/tags","blobs_url":"https://api.github.com/repos/libuv/libuv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libuv/libuv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libuv/libuv/git/refs{/sha}","trees_url":"https://api.github.com/repos/libuv/libuv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libuv/libuv/statuses/{sha}","languages_url":"https://api.github.com/repos/libuv/libuv/languages","stargazers_url":"https://api.github.com/repos/libuv/libuv/stargazers","contributors_url":"https://api.github.com/repos/libuv/libuv/contributors","subscribers_url":"https://api.github.com/repos/libuv/libuv/subscribers","subscription_url":"https://api.github.com/repos/libuv/libuv/subscription","commits_url":"https://api.github.com/repos/libuv/libuv/commits{/sha}","git_commits_url":"https://api.github.com/repos/libuv/libuv/git/commits{/sha}","comments_url":"https://api.github.com/repos/libuv/libuv/comments{/number}","issue_comment_url":"https://api.github.com/repos/libuv/libuv/issues/comments{/number}","contents_url":"https://api.github.com/repos/libuv/libuv/contents/{+path}","compare_url":"https://api.github.com/repos/libuv/libuv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libuv/libuv/merges","archive_url":"https://api.github.com/repos/libuv/libuv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libuv/libuv/downloads","issues_url":"https://api.github.com/repos/libuv/libuv/issues{/number}","pulls_url":"https://api.github.com/repos/libuv/libuv/pulls{/number}","milestones_url":"https://api.github.com/repos/libuv/libuv/milestones{/number}","notifications_url":"https://api.github.com/repos/libuv/libuv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libuv/libuv/labels{/name}","releases_url":"https://api.github.com/repos/libuv/libuv/releases{/id}","deployments_url":"https://api.github.com/repos/libuv/libuv/deployments","created_at":"2013-11-30T00:29:56Z","updated_at":"2016-04-12T16:01:28Z","pushed_at":"2016-04-12T17:03:28Z","git_url":"git://github.com/libuv/libuv.git","ssh_url":"git@github.com:libuv/libuv.git","clone_url":"https://github.com/libuv/libuv.git","svn_url":"https://github.com/libuv/libuv","homepage":"http://libuv.org/","size":17064,"stargazers_count":3648,"watchers_count":3648,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":583,"mirror_url":null,"open_issues_count":111,"forks":583,"open_issues":111,"watchers":3648,"default_branch":"v1.x"}},"_links":{"self":{"href":"https://api.github.com/repos/libuv/libuv/pulls/790"},"html":{"href":"https://github.com/libuv/libuv/pull/790"},"issue":{"href":"https://api.github.com/repos/libuv/libuv/issues/790"},"comments":{"href":"https://api.github.com/repos/libuv/libuv/issues/790/comments"},"review_comments":{"href":"https://api.github.com/repos/libuv/libuv/pulls/790/comments"},"review_comment":{"href":"https://api.github.com/repos/libuv/libuv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libuv/libuv/pulls/790/commits"},"statuses":{"href":"https://api.github.com/repos/libuv/libuv/statuses/2d22f4e5aa8ce3c8a7a1c62157d08fc2a6a7ed72"}}}}