{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/node/pulls/comments/168715052","pull_request_review_id":97128267,"id":168715052,"diff_hunk":"@@ -532,16 +533,17 @@ inline FSReqBase* AsyncDestCall(Environment* env,\n     uv_fs_t* uv_req = req_wrap->req();\n     uv_req->result = err;\n     uv_req->path = nullptr;\n-    after(uv_req);\n+    after(uv_req);  // after may delete req_wrap if there is an error\n     req_wrap = nullptr;\n   }\n \n   if (req_wrap != nullptr) {\n-    args.GetReturnValue().Set(req_wrap->persistent());\n+    req_wrap->SetReturnValue(args);","path":"src/node_file.cc","position":19,"original_position":19,"commit_id":"1fe23e0dd129fb6d67e00d05ec9d2978bc4778f5","original_commit_id":"1fe23e0dd129fb6d67e00d05ec9d2978bc4778f5","user":{"login":"joyeecheung","id":4299420,"avatar_url":"https://avatars0.githubusercontent.com/u/4299420?v=4","gravatar_id":"","url":"https://api.github.com/users/joyeecheung","html_url":"https://github.com/joyeecheung","followers_url":"https://api.github.com/users/joyeecheung/followers","following_url":"https://api.github.com/users/joyeecheung/following{/other_user}","gists_url":"https://api.github.com/users/joyeecheung/gists{/gist_id}","starred_url":"https://api.github.com/users/joyeecheung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyeecheung/subscriptions","organizations_url":"https://api.github.com/users/joyeecheung/orgs","repos_url":"https://api.github.com/users/joyeecheung/repos","events_url":"https://api.github.com/users/joyeecheung/events{/privacy}","received_events_url":"https://api.github.com/users/joyeecheung/received_events","type":"User","site_admin":false},"body":"@bnoordhuis Thanks, I think I understand what's going on with `uv_fs_copyfile` keeping the loop open when it errors out with `EINVAL` now..this seems to fix the problem:\r\n\r\n```diff\r\ndiff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c\r\nindex e0969a4c2f..f0446110f2 100644\r\n--- a/deps/uv/src/unix/fs.c\r\n+++ b/deps/uv/src/unix/fs.c\r\n@@ -1513,8 +1513,11 @@ int uv_fs_copyfile(uv_loop_t* loop,\r\n                    uv_fs_cb cb) {\r\n   INIT(COPYFILE);\r\n\r\n-  if (flags & ~UV_FS_COPYFILE_EXCL)\r\n+  if (flags & ~UV_FS_COPYFILE_EXCL) {\r\n+    if (cb != NULL)\r\n+      uv__req_unregister(loop, req);\r\n     return -EINVAL;\r\n+  }\r\n\r\n   PATH2;\r\n   req->flags = flags;\r\n```","created_at":"2018-02-16T10:02:15Z","updated_at":"2018-02-16T10:02:15Z","html_url":"https://github.com/nodejs/node/pull/18811#discussion_r168715052","pull_request_url":"https://api.github.com/repos/nodejs/node/pulls/18811","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments/168715052"},"html":{"href":"https://github.com/nodejs/node/pull/18811#discussion_r168715052"},"pull_request":{"href":"https://api.github.com/repos/nodejs/node/pulls/18811"}},"in_reply_to_id":168705219},"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/18811","id":169574049,"html_url":"https://github.com/nodejs/node/pull/18811","diff_url":"https://github.com/nodejs/node/pull/18811.diff","patch_url":"https://github.com/nodejs/node/pull/18811.patch","issue_url":"https://api.github.com/repos/nodejs/node/issues/18811","number":18811,"state":"open","locked":false,"title":"fs: fix potential segfault in async calls","user":{"login":"joyeecheung","id":4299420,"avatar_url":"https://avatars0.githubusercontent.com/u/4299420?v=4","gravatar_id":"","url":"https://api.github.com/users/joyeecheung","html_url":"https://github.com/joyeecheung","followers_url":"https://api.github.com/users/joyeecheung/followers","following_url":"https://api.github.com/users/joyeecheung/following{/other_user}","gists_url":"https://api.github.com/users/joyeecheung/gists{/gist_id}","starred_url":"https://api.github.com/users/joyeecheung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyeecheung/subscriptions","organizations_url":"https://api.github.com/users/joyeecheung/orgs","repos_url":"https://api.github.com/users/joyeecheung/repos","events_url":"https://api.github.com/users/joyeecheung/events{/privacy}","received_events_url":"https://api.github.com/users/joyeecheung/received_events","type":"User","site_admin":false},"body":"When the async uv_fs_* call errors out synchronously in AsyncDestCall,\r\nthe after callbacks (e.g. AfterNoArgs) would delete the req_wrap\r\nin FSReqAfterScope, and AsyncDestCall would set those req_wrap to\r\nnullptr afterwards. But when it returns to the top-layer bindings,\r\nthe bindings all call `req_wrap->SetReturnValue()` again without\r\nchecking if `req_wrap` is nullptr, causing a segfault.\r\n\r\nThis has not been caught in any of the tests because we usually do a lot\r\nof argument checking in the JS layer before invoking the uv_fs_*\r\nfunctions, so it's rare to get a synchronous error from them.\r\n\r\nCurrently we never need the binding to return the wrap to JS layer,\r\nso we can just call `req_wrap->SetReturnValue()` to return undefined for\r\nnormal FSReqWrap and the promise for FSReqPromise in AsyncDestCall instead\r\nof doing this in the top-level bindings.\r\n\r\n<!--\r\nThank you for your pull request. Please provide a description above and review\r\nthe requirements below.\r\n\r\nBug fixes and new features should include tests and possibly benchmarks.\r\n\r\nContributors guide: https://github.com/nodejs/node/blob/master/CONTRIBUTING.md\r\n-->\r\n\r\n##### Checklist\r\n<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->\r\n\r\n- [x] `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes\r\n- [x] tests and/or benchmarks are included\r\n- [ ] documentation is changed or added\r\n- [x] commit message follows [commit guidelines](https://github.com/nodejs/node/blob/master/doc/guides/contributing/pull-requests.md#commit-message-guidelines)\r\n\r\n##### Affected core subsystem(s)\r\n<!-- Provide affected core subsystem(s) (like doc, cluster, crypto, etc). -->\r\n","created_at":"2018-02-16T09:03:11Z","updated_at":"2018-02-16T10:02:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f4cd2c404ca18e34bf32301725a7a682a0f23d5","assignee":null,"assignees":[],"requested_reviewers":[{"login":"jasnell","id":439929,"avatar_url":"https://avatars2.githubusercontent.com/u/439929?v=4","gravatar_id":"","url":"https://api.github.com/users/jasnell","html_url":"https://github.com/jasnell","followers_url":"https://api.github.com/users/jasnell/followers","following_url":"https://api.github.com/users/jasnell/following{/other_user}","gists_url":"https://api.github.com/users/jasnell/gists{/gist_id}","starred_url":"https://api.github.com/users/jasnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasnell/subscriptions","organizations_url":"https://api.github.com/users/jasnell/orgs","repos_url":"https://api.github.com/users/jasnell/repos","events_url":"https://api.github.com/users/jasnell/events{/privacy}","received_events_url":"https://api.github.com/users/jasnell/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":155267502,"url":"https://api.github.com/repos/nodejs/node/labels/C++","name":"C++","color":"e11d21","default":false},{"id":155435785,"url":"https://api.github.com/repos/nodejs/node/labels/fs","name":"fs","color":"0052cc","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/node/pulls/18811/commits","review_comments_url":"https://api.github.com/repos/nodejs/node/pulls/18811/comments","review_comment_url":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node/issues/18811/comments","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/1fe23e0dd129fb6d67e00d05ec9d2978bc4778f5","head":{"label":"joyeecheung:fs-fix-segfault","ref":"fs-fix-segfault","sha":"1fe23e0dd129fb6d67e00d05ec9d2978bc4778f5","user":{"login":"joyeecheung","id":4299420,"avatar_url":"https://avatars0.githubusercontent.com/u/4299420?v=4","gravatar_id":"","url":"https://api.github.com/users/joyeecheung","html_url":"https://github.com/joyeecheung","followers_url":"https://api.github.com/users/joyeecheung/followers","following_url":"https://api.github.com/users/joyeecheung/following{/other_user}","gists_url":"https://api.github.com/users/joyeecheung/gists{/gist_id}","starred_url":"https://api.github.com/users/joyeecheung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyeecheung/subscriptions","organizations_url":"https://api.github.com/users/joyeecheung/orgs","repos_url":"https://api.github.com/users/joyeecheung/repos","events_url":"https://api.github.com/users/joyeecheung/events{/privacy}","received_events_url":"https://api.github.com/users/joyeecheung/received_events","type":"User","site_admin":false},"repo":{"id":75291879,"name":"node","full_name":"joyeecheung/node","owner":{"login":"joyeecheung","id":4299420,"avatar_url":"https://avatars0.githubusercontent.com/u/4299420?v=4","gravatar_id":"","url":"https://api.github.com/users/joyeecheung","html_url":"https://github.com/joyeecheung","followers_url":"https://api.github.com/users/joyeecheung/followers","following_url":"https://api.github.com/users/joyeecheung/following{/other_user}","gists_url":"https://api.github.com/users/joyeecheung/gists{/gist_id}","starred_url":"https://api.github.com/users/joyeecheung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyeecheung/subscriptions","organizations_url":"https://api.github.com/users/joyeecheung/orgs","repos_url":"https://api.github.com/users/joyeecheung/repos","events_url":"https://api.github.com/users/joyeecheung/events{/privacy}","received_events_url":"https://api.github.com/users/joyeecheung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joyeecheung/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":true,"url":"https://api.github.com/repos/joyeecheung/node","forks_url":"https://api.github.com/repos/joyeecheung/node/forks","keys_url":"https://api.github.com/repos/joyeecheung/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joyeecheung/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joyeecheung/node/teams","hooks_url":"https://api.github.com/repos/joyeecheung/node/hooks","issue_events_url":"https://api.github.com/repos/joyeecheung/node/issues/events{/number}","events_url":"https://api.github.com/repos/joyeecheung/node/events","assignees_url":"https://api.github.com/repos/joyeecheung/node/assignees{/user}","branches_url":"https://api.github.com/repos/joyeecheung/node/branches{/branch}","tags_url":"https://api.github.com/repos/joyeecheung/node/tags","blobs_url":"https://api.github.com/repos/joyeecheung/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joyeecheung/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joyeecheung/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/joyeecheung/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joyeecheung/node/statuses/{sha}","languages_url":"https://api.github.com/repos/joyeecheung/node/languages","stargazers_url":"https://api.github.com/repos/joyeecheung/node/stargazers","contributors_url":"https://api.github.com/repos/joyeecheung/node/contributors","subscribers_url":"https://api.github.com/repos/joyeecheung/node/subscribers","subscription_url":"https://api.github.com/repos/joyeecheung/node/subscription","commits_url":"https://api.github.com/repos/joyeecheung/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/joyeecheung/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/joyeecheung/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/joyeecheung/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/joyeecheung/node/contents/{+path}","compare_url":"https://api.github.com/repos/joyeecheung/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joyeecheung/node/merges","archive_url":"https://api.github.com/repos/joyeecheung/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joyeecheung/node/downloads","issues_url":"https://api.github.com/repos/joyeecheung/node/issues{/number}","pulls_url":"https://api.github.com/repos/joyeecheung/node/pulls{/number}","milestones_url":"https://api.github.com/repos/joyeecheung/node/milestones{/number}","notifications_url":"https://api.github.com/repos/joyeecheung/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joyeecheung/node/labels{/name}","releases_url":"https://api.github.com/repos/joyeecheung/node/releases{/id}","deployments_url":"https://api.github.com/repos/joyeecheung/node/deployments","created_at":"2016-12-01T12:47:03Z","updated_at":"2017-11-05T02:59:35Z","pushed_at":"2018-02-16T08:44:23Z","git_url":"git://github.com/joyeecheung/node.git","ssh_url":"git@github.com:joyeecheung/node.git","clone_url":"https://github.com/joyeecheung/node.git","svn_url":"https://github.com/joyeecheung/node","homepage":"https://nodejs.org","size":340338,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nodejs:master","ref":"master","sha":"42c14c5c17c427aa82722fff41f3e723354239b9","user":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars3.githubusercontent.com/u/9950313?v=4","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":27193779,"name":"node","full_name":"nodejs/node","owner":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars3.githubusercontent.com/u/9950313?v=4","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodejs/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":false,"url":"https://api.github.com/repos/nodejs/node","forks_url":"https://api.github.com/repos/nodejs/node/forks","keys_url":"https://api.github.com/repos/nodejs/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/node/teams","hooks_url":"https://api.github.com/repos/nodejs/node/hooks","issue_events_url":"https://api.github.com/repos/nodejs/node/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/node/events","assignees_url":"https://api.github.com/repos/nodejs/node/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/node/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/node/tags","blobs_url":"https://api.github.com/repos/nodejs/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/node/languages","stargazers_url":"https://api.github.com/repos/nodejs/node/stargazers","contributors_url":"https://api.github.com/repos/nodejs/node/contributors","subscribers_url":"https://api.github.com/repos/nodejs/node/subscribers","subscription_url":"https://api.github.com/repos/nodejs/node/subscription","commits_url":"https://api.github.com/repos/nodejs/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/node/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/node/merges","archive_url":"https://api.github.com/repos/nodejs/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/node/downloads","issues_url":"https://api.github.com/repos/nodejs/node/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/node/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/node/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/node/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/node/releases{/id}","deployments_url":"https://api.github.com/repos/nodejs/node/deployments","created_at":"2014-11-26T19:57:11Z","updated_at":"2018-02-16T08:46:56Z","pushed_at":"2018-02-16T09:43:30Z","git_url":"git://github.com/nodejs/node.git","ssh_url":"git@github.com:nodejs/node.git","clone_url":"https://github.com/nodejs/node.git","svn_url":"https://github.com/nodejs/node","homepage":"https://nodejs.org","size":348010,"stargazers_count":45518,"watchers_count":45518,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9552,"mirror_url":null,"archived":false,"open_issues_count":818,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":9552,"open_issues":818,"watchers":45518,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/18811"},"html":{"href":"https://github.com/nodejs/node/pull/18811"},"issue":{"href":"https://api.github.com/repos/nodejs/node/issues/18811"},"comments":{"href":"https://api.github.com/repos/nodejs/node/issues/18811/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node/pulls/18811/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node/pulls/18811/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node/statuses/1fe23e0dd129fb6d67e00d05ec9d2978bc4778f5"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"joyeecheung"}}