{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/210999733","pull_request_review_id":147339482,"id":210999733,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMDk5OTczMw==","diff_hunk":"@@ -100,10 +100,11 @@ extension MTLDevice {\n @available(swift 4)\n @available(macOS 10.13, *)\n public func MTLCopyAllDevicesWithObserver(handler: @escaping MTLDeviceNotificationHandler) -> (devices:[MTLDevice], observer:NSObject) {\n-    var resultTuple: (devices:[MTLDevice], observer:NSObject)\n-    resultTuple.observer = NSObject()\n-    resultTuple.devices = __MTLCopyAllDevicesWithObserver(AutoreleasingUnsafeMutablePointer<NSObjectProtocol?>(&resultTuple.observer), handler)\n-    return resultTuple\n+    var observer: NSObjectProtocol?\n+    let devices = __MTLCopyAllDevicesWithObserver(&observer, handler)\n+    // FIX-ME: The force cast here isn't great – ideally we would return the\n+    // observer as an NSObjectProtocol.\n+    return (devices, observer as! NSObject)","path":"stdlib/public/SDK/Metal/Metal.swift","position":12,"original_position":12,"commit_id":"d07ff797ff8d09dee7d1fcd9e92a556bca52fc79","original_commit_id":"d07ff797ff8d09dee7d1fcd9e92a556bca52fc79","user":{"login":"hamishknight","id":14794099,"node_id":"MDQ6VXNlcjE0Nzk0MDk5","avatar_url":"https://avatars0.githubusercontent.com/u/14794099?v=4","gravatar_id":"","url":"https://api.github.com/users/hamishknight","html_url":"https://github.com/hamishknight","followers_url":"https://api.github.com/users/hamishknight/followers","following_url":"https://api.github.com/users/hamishknight/following{/other_user}","gists_url":"https://api.github.com/users/hamishknight/gists{/gist_id}","starred_url":"https://api.github.com/users/hamishknight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hamishknight/subscriptions","organizations_url":"https://api.github.com/users/hamishknight/orgs","repos_url":"https://api.github.com/users/hamishknight/repos","events_url":"https://api.github.com/users/hamishknight/events{/privacy}","received_events_url":"https://api.github.com/users/hamishknight/received_events","type":"User","site_admin":false},"body":"Also, can I confirm that `__MTLCopyAllDevicesWithObserver` is guaranteed to set `observer`? The previous code was initially assigning `NSObject()`, but I'm not sure whether that was specifically because it could actually return that as the observer.","created_at":"2018-08-17T18:42:18Z","updated_at":"2018-08-17T18:42:19Z","html_url":"https://github.com/apple/swift/pull/18799#discussion_r210999733","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/18799","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/210999733"},"html":{"href":"https://github.com/apple/swift/pull/18799#discussion_r210999733"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/18799"}},"in_reply_to_id":210996989},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/18799","id":209225078,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5MjI1MDc4","html_url":"https://github.com/apple/swift/pull/18799","diff_url":"https://github.com/apple/swift/pull/18799.diff","patch_url":"https://github.com/apple/swift/pull/18799.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/18799","number":18799,"state":"open","locked":false,"title":"[stdlib] Clean up some sources of undefined behaviour","user":{"login":"hamishknight","id":14794099,"node_id":"MDQ6VXNlcjE0Nzk0MDk5","avatar_url":"https://avatars0.githubusercontent.com/u/14794099?v=4","gravatar_id":"","url":"https://api.github.com/users/hamishknight","html_url":"https://github.com/hamishknight","followers_url":"https://api.github.com/users/hamishknight/followers","following_url":"https://api.github.com/users/hamishknight/following{/other_user}","gists_url":"https://api.github.com/users/hamishknight/gists{/gist_id}","starred_url":"https://api.github.com/users/hamishknight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hamishknight/subscriptions","organizations_url":"https://api.github.com/users/hamishknight/orgs","repos_url":"https://api.github.com/users/hamishknight/repos","events_url":"https://api.github.com/users/hamishknight/events{/privacy}","received_events_url":"https://api.github.com/users/hamishknight/received_events","type":"User","site_admin":false},"body":"While experimenting with forbidding temporary argument conversions for `UnsafePointer` initialiser parameters (amongst others), I found a few cases where we're currently making such unsound calls in the SDK overlays.\r\n\r\nThis commit removes such usages by performing the temporary argument conversions directly without going through any `UnsafePointer` initialiser calls first.\r\n\r\nIn the case of `MTLCopyAllDevicesWithObserver`, we were even over-releasing the observer through the usage of:\r\n\r\n```swift\r\nAutoreleasingUnsafeMutablePointer<NSObjectProtocol?>(&resultTuple.observer)\r\n```\r\n\r\nAs we were treating +1 memory as having +0 semantics (this didn't appear to cause issues for users though as Metal itself appears to keep the observer retained).\r\n","created_at":"2018-08-17T18:31:33Z","updated_at":"2018-08-17T18:42:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e9f294a41a71a666165c70c0920bd94b3e086a9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift/pulls/18799/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/18799/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/18799/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/d07ff797ff8d09dee7d1fcd9e92a556bca52fc79","head":{"label":"hamishknight:ub-good-now","ref":"ub-good-now","sha":"d07ff797ff8d09dee7d1fcd9e92a556bca52fc79","user":{"login":"hamishknight","id":14794099,"node_id":"MDQ6VXNlcjE0Nzk0MDk5","avatar_url":"https://avatars0.githubusercontent.com/u/14794099?v=4","gravatar_id":"","url":"https://api.github.com/users/hamishknight","html_url":"https://github.com/hamishknight","followers_url":"https://api.github.com/users/hamishknight/followers","following_url":"https://api.github.com/users/hamishknight/following{/other_user}","gists_url":"https://api.github.com/users/hamishknight/gists{/gist_id}","starred_url":"https://api.github.com/users/hamishknight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hamishknight/subscriptions","organizations_url":"https://api.github.com/users/hamishknight/orgs","repos_url":"https://api.github.com/users/hamishknight/repos","events_url":"https://api.github.com/users/hamishknight/events{/privacy}","received_events_url":"https://api.github.com/users/hamishknight/received_events","type":"User","site_admin":false},"repo":{"id":106924558,"node_id":"MDEwOlJlcG9zaXRvcnkxMDY5MjQ1NTg=","name":"swift","full_name":"hamishknight/swift","owner":{"login":"hamishknight","id":14794099,"node_id":"MDQ6VXNlcjE0Nzk0MDk5","avatar_url":"https://avatars0.githubusercontent.com/u/14794099?v=4","gravatar_id":"","url":"https://api.github.com/users/hamishknight","html_url":"https://github.com/hamishknight","followers_url":"https://api.github.com/users/hamishknight/followers","following_url":"https://api.github.com/users/hamishknight/following{/other_user}","gists_url":"https://api.github.com/users/hamishknight/gists{/gist_id}","starred_url":"https://api.github.com/users/hamishknight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hamishknight/subscriptions","organizations_url":"https://api.github.com/users/hamishknight/orgs","repos_url":"https://api.github.com/users/hamishknight/repos","events_url":"https://api.github.com/users/hamishknight/events{/privacy}","received_events_url":"https://api.github.com/users/hamishknight/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hamishknight/swift","description":"The Swift Programming Language","fork":true,"url":"https://api.github.com/repos/hamishknight/swift","forks_url":"https://api.github.com/repos/hamishknight/swift/forks","keys_url":"https://api.github.com/repos/hamishknight/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hamishknight/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hamishknight/swift/teams","hooks_url":"https://api.github.com/repos/hamishknight/swift/hooks","issue_events_url":"https://api.github.com/repos/hamishknight/swift/issues/events{/number}","events_url":"https://api.github.com/repos/hamishknight/swift/events","assignees_url":"https://api.github.com/repos/hamishknight/swift/assignees{/user}","branches_url":"https://api.github.com/repos/hamishknight/swift/branches{/branch}","tags_url":"https://api.github.com/repos/hamishknight/swift/tags","blobs_url":"https://api.github.com/repos/hamishknight/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hamishknight/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hamishknight/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/hamishknight/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hamishknight/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/hamishknight/swift/languages","stargazers_url":"https://api.github.com/repos/hamishknight/swift/stargazers","contributors_url":"https://api.github.com/repos/hamishknight/swift/contributors","subscribers_url":"https://api.github.com/repos/hamishknight/swift/subscribers","subscription_url":"https://api.github.com/repos/hamishknight/swift/subscription","commits_url":"https://api.github.com/repos/hamishknight/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/hamishknight/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/hamishknight/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/hamishknight/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/hamishknight/swift/contents/{+path}","compare_url":"https://api.github.com/repos/hamishknight/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hamishknight/swift/merges","archive_url":"https://api.github.com/repos/hamishknight/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hamishknight/swift/downloads","issues_url":"https://api.github.com/repos/hamishknight/swift/issues{/number}","pulls_url":"https://api.github.com/repos/hamishknight/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/hamishknight/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/hamishknight/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hamishknight/swift/labels{/name}","releases_url":"https://api.github.com/repos/hamishknight/swift/releases{/id}","deployments_url":"https://api.github.com/repos/hamishknight/swift/deployments","created_at":"2017-10-14T12:05:30Z","updated_at":"2018-08-17T18:06:36Z","pushed_at":"2018-08-17T18:27:37Z","git_url":"git://github.com/hamishknight/swift.git","ssh_url":"git@github.com:hamishknight/swift.git","clone_url":"https://github.com/hamishknight/swift.git","svn_url":"https://github.com/hamishknight/swift","homepage":"https://swift.org/","size":313554,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"935641284ac8882fe0b0880e91ea6830c7c35569","user":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"repo":{"id":44838949,"node_id":"MDEwOlJlcG9zaXRvcnk0NDgzODk0OQ==","name":"swift","full_name":"apple/swift","owner":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apple/swift","description":"The Swift Programming Language","fork":false,"url":"https://api.github.com/repos/apple/swift","forks_url":"https://api.github.com/repos/apple/swift/forks","keys_url":"https://api.github.com/repos/apple/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift/teams","hooks_url":"https://api.github.com/repos/apple/swift/hooks","issue_events_url":"https://api.github.com/repos/apple/swift/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift/events","assignees_url":"https://api.github.com/repos/apple/swift/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift/tags","blobs_url":"https://api.github.com/repos/apple/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift/languages","stargazers_url":"https://api.github.com/repos/apple/swift/stargazers","contributors_url":"https://api.github.com/repos/apple/swift/contributors","subscribers_url":"https://api.github.com/repos/apple/swift/subscribers","subscription_url":"https://api.github.com/repos/apple/swift/subscription","commits_url":"https://api.github.com/repos/apple/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift/merges","archive_url":"https://api.github.com/repos/apple/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift/downloads","issues_url":"https://api.github.com/repos/apple/swift/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift/deployments","created_at":"2015-10-23T21:15:07Z","updated_at":"2018-08-17T18:34:44Z","pushed_at":"2018-08-17T18:31:33Z","git_url":"git://github.com/apple/swift.git","ssh_url":"git@github.com:apple/swift.git","clone_url":"https://github.com/apple/swift.git","svn_url":"https://github.com/apple/swift","homepage":"https://swift.org/","size":327754,"stargazers_count":44885,"watchers_count":44885,"language":"C++","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7079,"mirror_url":null,"archived":false,"open_issues_count":381,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":7079,"open_issues":381,"watchers":44885,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/18799"},"html":{"href":"https://github.com/apple/swift/pull/18799"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/18799"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/18799/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/18799/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/18799/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/d07ff797ff8d09dee7d1fcd9e92a556bca52fc79"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"hamishknight"}}