{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/208381085","pull_request_review_id":144179595,"id":208381085,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwODM4MTA4NQ==","diff_hunk":"@@ -26,7 +26,11 @@ const fn done<T>() -> *mut Arc<T> { 1_usize as *mut _ }\n unsafe impl<T> Sync for Lazy<T> {}\n \n impl<T: Send + Sync + 'static> Lazy<T> {\n-    pub const fn new(init: fn() -> Arc<T>) -> Lazy<T> {\n+    /// Safety: `init` must not call `get` on the variable that is being\n+    /// initialized.\n+    pub const unsafe fn new(init: fn() -> Arc<T>) -> Lazy<T> {\n+        // `lock` is never initialized fully, so it is UB to attempt to","path":"src/libstd/io/lazy.rs","position":8,"original_position":8,"commit_id":"645388583ca47357a6a2e5878a9cde84e2e579d3","original_commit_id":"645388583ca47357a6a2e5878a9cde84e2e579d3","user":{"login":"alexcrichton","id":64996,"node_id":"MDQ6VXNlcjY0OTk2","avatar_url":"https://avatars1.githubusercontent.com/u/64996?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"body":"This threw me for a spin when I first read it, could it perhaps be reworded? In the Rust sense we fully initialize the lock (aka put valid bytes in place) but what this comment is alluding to is the POSIX-specific behavior tweak in the mutex implementation where `Mutex::new` isn't as safe as an `init`'d mutex. Could this perhaps be reworded as:\r\n\r\n> `lock` is not valid to use in a reentrant fashion, causing UB if that happens;\r\n> for more information see comments in <path> ","created_at":"2018-08-07T20:52:11Z","updated_at":"2018-08-07T20:55:12Z","html_url":"https://github.com/rust-lang/rust/pull/53108#discussion_r208381085","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/53108","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/208381085"},"html":{"href":"https://github.com/rust-lang/rust/pull/53108#discussion_r208381085"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/53108"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/53108","id":206361737,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2MzYxNzM3","html_url":"https://github.com/rust-lang/rust/pull/53108","diff_url":"https://github.com/rust-lang/rust/pull/53108.diff","patch_url":"https://github.com/rust-lang/rust/pull/53108.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/53108","number":53108,"state":"open","locked":false,"title":"clarify partially initialized Mutex issues","user":{"login":"RalfJung","id":330628,"node_id":"MDQ6VXNlcjMzMDYyOA==","avatar_url":"https://avatars1.githubusercontent.com/u/330628?v=4","gravatar_id":"","url":"https://api.github.com/users/RalfJung","html_url":"https://github.com/RalfJung","followers_url":"https://api.github.com/users/RalfJung/followers","following_url":"https://api.github.com/users/RalfJung/following{/other_user}","gists_url":"https://api.github.com/users/RalfJung/gists{/gist_id}","starred_url":"https://api.github.com/users/RalfJung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RalfJung/subscriptions","organizations_url":"https://api.github.com/users/RalfJung/orgs","repos_url":"https://api.github.com/users/RalfJung/repos","events_url":"https://api.github.com/users/RalfJung/events{/privacy}","received_events_url":"https://api.github.com/users/RalfJung/received_events","type":"User","site_admin":false},"body":"Using a `sys_common::mutex::Mutex` without calling `init` is dangerous, and yet there are some places that do this. I tried to find all of them and add an appropriate comment about reentrancy.\r\n\r\nI found two places where (I think) reentrancy can actually occur, and was not able to come up with an argument for why this is okay. Someone who knows `io::lazy` and/or `sys_common::at_exit_imp` should have a careful look at this.","created_at":"2018-08-06T10:55:51Z","updated_at":"2018-08-07T20:55:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d682509e58e49cb86cee2a67408b818b726925cd","assignee":{"login":"TimNN","id":1178249,"node_id":"MDQ6VXNlcjExNzgyNDk=","avatar_url":"https://avatars3.githubusercontent.com/u/1178249?v=4","gravatar_id":"","url":"https://api.github.com/users/TimNN","html_url":"https://github.com/TimNN","followers_url":"https://api.github.com/users/TimNN/followers","following_url":"https://api.github.com/users/TimNN/following{/other_user}","gists_url":"https://api.github.com/users/TimNN/gists{/gist_id}","starred_url":"https://api.github.com/users/TimNN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimNN/subscriptions","organizations_url":"https://api.github.com/users/TimNN/orgs","repos_url":"https://api.github.com/users/TimNN/repos","events_url":"https://api.github.com/users/TimNN/events{/privacy}","received_events_url":"https://api.github.com/users/TimNN/received_events","type":"User","site_admin":false},"assignees":[{"login":"TimNN","id":1178249,"node_id":"MDQ6VXNlcjExNzgyNDk=","avatar_url":"https://avatars3.githubusercontent.com/u/1178249?v=4","gravatar_id":"","url":"https://api.github.com/users/TimNN","html_url":"https://github.com/TimNN","followers_url":"https://api.github.com/users/TimNN/followers","following_url":"https://api.github.com/users/TimNN/following{/other_user}","gists_url":"https://api.github.com/users/TimNN/gists{/gist_id}","starred_url":"https://api.github.com/users/TimNN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimNN/subscriptions","organizations_url":"https://api.github.com/users/TimNN/orgs","repos_url":"https://api.github.com/users/TimNN/repos","events_url":"https://api.github.com/users/TimNN/events{/privacy}","received_events_url":"https://api.github.com/users/TimNN/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":583426710,"node_id":"MDU6TGFiZWw1ODM0MjY3MTA=","url":"https://api.github.com/repos/rust-lang/rust/labels/S-waiting-on-review","name":"S-waiting-on-review","color":"d3dddd","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/53108/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/53108/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/53108/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/645388583ca47357a6a2e5878a9cde84e2e579d3","head":{"label":"RalfJung:mutex","ref":"mutex","sha":"645388583ca47357a6a2e5878a9cde84e2e579d3","user":{"login":"RalfJung","id":330628,"node_id":"MDQ6VXNlcjMzMDYyOA==","avatar_url":"https://avatars1.githubusercontent.com/u/330628?v=4","gravatar_id":"","url":"https://api.github.com/users/RalfJung","html_url":"https://github.com/RalfJung","followers_url":"https://api.github.com/users/RalfJung/followers","following_url":"https://api.github.com/users/RalfJung/following{/other_user}","gists_url":"https://api.github.com/users/RalfJung/gists{/gist_id}","starred_url":"https://api.github.com/users/RalfJung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RalfJung/subscriptions","organizations_url":"https://api.github.com/users/RalfJung/orgs","repos_url":"https://api.github.com/users/RalfJung/repos","events_url":"https://api.github.com/users/RalfJung/events{/privacy}","received_events_url":"https://api.github.com/users/RalfJung/received_events","type":"User","site_admin":false},"repo":{"id":81860024,"node_id":"MDEwOlJlcG9zaXRvcnk4MTg2MDAyNA==","name":"rust","full_name":"RalfJung/rust","owner":{"login":"RalfJung","id":330628,"node_id":"MDQ6VXNlcjMzMDYyOA==","avatar_url":"https://avatars1.githubusercontent.com/u/330628?v=4","gravatar_id":"","url":"https://api.github.com/users/RalfJung","html_url":"https://github.com/RalfJung","followers_url":"https://api.github.com/users/RalfJung/followers","following_url":"https://api.github.com/users/RalfJung/following{/other_user}","gists_url":"https://api.github.com/users/RalfJung/gists{/gist_id}","starred_url":"https://api.github.com/users/RalfJung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RalfJung/subscriptions","organizations_url":"https://api.github.com/users/RalfJung/orgs","repos_url":"https://api.github.com/users/RalfJung/repos","events_url":"https://api.github.com/users/RalfJung/events{/privacy}","received_events_url":"https://api.github.com/users/RalfJung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RalfJung/rust","description":"A safe, concurrent, practical language.","fork":true,"url":"https://api.github.com/repos/RalfJung/rust","forks_url":"https://api.github.com/repos/RalfJung/rust/forks","keys_url":"https://api.github.com/repos/RalfJung/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RalfJung/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RalfJung/rust/teams","hooks_url":"https://api.github.com/repos/RalfJung/rust/hooks","issue_events_url":"https://api.github.com/repos/RalfJung/rust/issues/events{/number}","events_url":"https://api.github.com/repos/RalfJung/rust/events","assignees_url":"https://api.github.com/repos/RalfJung/rust/assignees{/user}","branches_url":"https://api.github.com/repos/RalfJung/rust/branches{/branch}","tags_url":"https://api.github.com/repos/RalfJung/rust/tags","blobs_url":"https://api.github.com/repos/RalfJung/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RalfJung/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RalfJung/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/RalfJung/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RalfJung/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/RalfJung/rust/languages","stargazers_url":"https://api.github.com/repos/RalfJung/rust/stargazers","contributors_url":"https://api.github.com/repos/RalfJung/rust/contributors","subscribers_url":"https://api.github.com/repos/RalfJung/rust/subscribers","subscription_url":"https://api.github.com/repos/RalfJung/rust/subscription","commits_url":"https://api.github.com/repos/RalfJung/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/RalfJung/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/RalfJung/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/RalfJung/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/RalfJung/rust/contents/{+path}","compare_url":"https://api.github.com/repos/RalfJung/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RalfJung/rust/merges","archive_url":"https://api.github.com/repos/RalfJung/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RalfJung/rust/downloads","issues_url":"https://api.github.com/repos/RalfJung/rust/issues{/number}","pulls_url":"https://api.github.com/repos/RalfJung/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/RalfJung/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/RalfJung/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RalfJung/rust/labels{/name}","releases_url":"https://api.github.com/repos/RalfJung/rust/releases{/id}","deployments_url":"https://api.github.com/repos/RalfJung/rust/deployments","created_at":"2017-02-13T18:59:58Z","updated_at":"2018-07-23T09:16:07Z","pushed_at":"2018-08-07T09:57:49Z","git_url":"git://github.com/RalfJung/rust.git","ssh_url":"git@github.com:RalfJung/rust.git","clone_url":"https://github.com/RalfJung/rust.git","svn_url":"https://github.com/RalfJung/rust","homepage":"https://www.rust-lang.org","size":382862,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"7c98d2e63f732682b057c8c453b08f9e12b262e6","user":{"login":"rust-lang","id":5430905,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MzA5MDU=","avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":724712,"node_id":"MDEwOlJlcG9zaXRvcnk3MjQ3MTI=","name":"rust","full_name":"rust-lang/rust","owner":{"login":"rust-lang","id":5430905,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MzA5MDU=","avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/rust","description":"A safe, concurrent, practical language.","fork":false,"url":"https://api.github.com/repos/rust-lang/rust","forks_url":"https://api.github.com/repos/rust-lang/rust/forks","keys_url":"https://api.github.com/repos/rust-lang/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rust/teams","hooks_url":"https://api.github.com/repos/rust-lang/rust/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rust/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rust/events","assignees_url":"https://api.github.com/repos/rust-lang/rust/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rust/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rust/tags","blobs_url":"https://api.github.com/repos/rust-lang/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rust/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rust/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rust/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rust/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rust/subscription","commits_url":"https://api.github.com/repos/rust-lang/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/rust/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rust/merges","archive_url":"https://api.github.com/repos/rust-lang/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rust/downloads","issues_url":"https://api.github.com/repos/rust-lang/rust/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rust/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rust/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/rust/deployments","created_at":"2010-06-16T20:39:03Z","updated_at":"2018-08-07T20:54:31Z","pushed_at":"2018-08-07T20:33:51Z","git_url":"git://github.com/rust-lang/rust.git","ssh_url":"git@github.com:rust-lang/rust.git","clone_url":"https://github.com/rust-lang/rust.git","svn_url":"https://github.com/rust-lang/rust","homepage":"https://www.rust-lang.org","size":384817,"stargazers_count":29859,"watchers_count":29859,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5103,"mirror_url":null,"archived":false,"open_issues_count":4114,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":5103,"open_issues":4114,"watchers":29859,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/53108"},"html":{"href":"https://github.com/rust-lang/rust/pull/53108"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/53108"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/53108/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/53108/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/53108/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/645388583ca47357a6a2e5878a9cde84e2e579d3"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"alexcrichton"}}