{"action":"created","issue":{"url":"https://api.github.com/repos/apple/swift/issues/18799","repository_url":"https://api.github.com/repos/apple/swift","labels_url":"https://api.github.com/repos/apple/swift/issues/18799/labels{/name}","comments_url":"https://api.github.com/repos/apple/swift/issues/18799/comments","events_url":"https://api.github.com/repos/apple/swift/issues/18799/events","html_url":"https://github.com/apple/swift/pull/18799","id":351696501,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5MjI1MDc4","number":18799,"title":"[overlays] 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},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-17T18:31:33Z","updated_at":"2018-09-27T13:56:18Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/18799","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"},"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 (unsound because such temporary argument conversions produce pointers valid only for the duration of the call).\r\n\r\nThis PR 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`, such usage led to us over-releasing the observer, as the call to `AutoreleasingUnsafeMutablePointer`'s initialiser:\r\n\r\n```swift\r\nAutoreleasingUnsafeMutablePointer<NSObjectProtocol?>(&resultTuple.observer)\r\n```\r\n\r\ntreats the +1 memory as having +0 semantics, leading to an unbalanced autorelease (this didn't appear to cause issues for users though as Metal itself keeps the observer retained).\r\n"},"comment":{"url":"https://api.github.com/repos/apple/swift/issues/comments/425102246","html_url":"https://github.com/apple/swift/pull/18799#issuecomment-425102246","issue_url":"https://api.github.com/repos/apple/swift/issues/18799","id":425102246,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTEwMjI0Ng==","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},"created_at":"2018-09-27T13:56:18Z","updated_at":"2018-09-27T13:56:18Z","author_association":"CONTRIBUTOR","body":"Review ping @lancep @moiseev"}}
{"actor":{"display_login":"hamishknight"}}