{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/67962189","id":67962189,"diff_hunk":"@@ -12,44 +12,57 @@\n \n import SwiftShims\n \n-internal class _Box<Wrapped> {\n-  internal var _value: Wrapped\n-  internal init(_ value: Wrapped) { self._value = value }\n-}\n-\n /// Command-line arguments for the current process.\n public enum Process {\n   /// Return an array of string containing the list of command-line arguments\n   /// with which the current process was invoked.\n   internal static func _computeArguments() -> [String] {\n     var result: [String] = []\n-    let argv = unsafeArgv\n-    for i in 0..<Int(argc) {\n-      let arg = argv[i]!\n-      let converted = String(cString: arg)\n-      result.append(converted)\n+    if let argv = _unsafeArgv {\n+      for i in 0..<Int(argc) {\n+        let arg = argv[i]!\n+        let converted = String(cString:arg)\n+        result.append(converted)\n+      }\n     }\n-    return result \n+    return result\n   }\n \n   @_versioned\n+  /// The backing static variable for argument count may come either from the\n+  /// entry point or it may need to be computed e.g. if we're in the REPL.\n   internal static var _argc: CInt = CInt()\n-\n+  \n   @_versioned\n   internal static var _unsafeArgv:\n-    UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>?\n-    = nil\n-\n+    /// The backing static variable for arguments may come either from the\n+    /// entry point or it may need to be computed e.g. if we're in the REPL.\n+    ///\n+    /// Care must be taken to ensure that `_swift_stdlib_getUnsafeArgcArgv` is\n+    /// not invoked more times than is necessary (at most once).\n+    UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>? = nil\n+  \n   /// Access to the raw argc value from C.\n   public static var argc: CInt {\n+    _ = Process.unsafeArgv // Force strict evaulation of _unsafeArgv.\n     return _argc\n   }\n \n   /// Access to the raw argv value from C. Accessing the argument vector\n   /// through this pointer is unsafe.\n   public static var unsafeArgv:\n     UnsafeMutablePointer<UnsafeMutablePointer<Int8>?> {\n-    return _unsafeArgv!\n+    let argumentsPtr = UnsafeMutablePointer<AnyObject?>(\n+      Builtin.addressof(&_swift_stdlib_ProcessUnsafeArgv))\n+\n+    let newArgs = _unsafeArgv ?? _swift_stdlib_getUnsafeArgcArgv(&_argc)\n+    if _stdlib_atomicCompareExchangeStrongPtr(\n+      object: argumentsPtr, expected: &_swift_stdlib_ProcessUnsafeArgv, desired: newArgs) {","path":"stdlib/public/core/Process.swift","position":65,"original_position":65,"commit_id":"0f1b64bc7188356c9a299f347fdbf78a2994788f","original_commit_id":"0f1b64bc7188356c9a299f347fdbf78a2994788f","user":{"login":"gribozavr","id":1120569,"avatar_url":"https://avatars.githubusercontent.com/u/1120569?v=3","gravatar_id":"","url":"https://api.github.com/users/gribozavr","html_url":"https://github.com/gribozavr","followers_url":"https://api.github.com/users/gribozavr/followers","following_url":"https://api.github.com/users/gribozavr/following{/other_user}","gists_url":"https://api.github.com/users/gribozavr/gists{/gist_id}","starred_url":"https://api.github.com/users/gribozavr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gribozavr/subscriptions","organizations_url":"https://api.github.com/users/gribozavr/orgs","repos_url":"https://api.github.com/users/gribozavr/repos","events_url":"https://api.github.com/users/gribozavr/events{/privacy}","received_events_url":"https://api.github.com/users/gribozavr/received_events","type":"User","site_admin":false},"body":"Expected should be `nil`.  We are initializing `_swift_stdlib_ProcessUnsafeArgv` from nil to `newArgs`.","created_at":"2016-06-21T22:13:45Z","updated_at":"2016-06-21T22:13:45Z","html_url":"https://github.com/apple/swift/pull/3108#discussion_r67962189","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/3108","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/67962189"},"html":{"href":"https://github.com/apple/swift/pull/3108#discussion_r67962189"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/3108"}}},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/3108","id":74668088,"html_url":"https://github.com/apple/swift/pull/3108","diff_url":"https://github.com/apple/swift/pull/3108.diff","patch_url":"https://github.com/apple/swift/pull/3108.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/3108","number":3108,"state":"open","locked":false,"title":"[Stdlib] Fix entry-point-based process args","user":{"login":"CodaFi","id":1896383,"avatar_url":"https://avatars.githubusercontent.com/u/1896383?v=3","gravatar_id":"","url":"https://api.github.com/users/CodaFi","html_url":"https://github.com/CodaFi","followers_url":"https://api.github.com/users/CodaFi/followers","following_url":"https://api.github.com/users/CodaFi/following{/other_user}","gists_url":"https://api.github.com/users/CodaFi/gists{/gist_id}","starred_url":"https://api.github.com/users/CodaFi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CodaFi/subscriptions","organizations_url":"https://api.github.com/users/CodaFi/orgs","repos_url":"https://api.github.com/users/CodaFi/repos","events_url":"https://api.github.com/users/CodaFi/events{/privacy}","received_events_url":"https://api.github.com/users/CodaFi/received_events","type":"User","site_admin":false},"body":"<!-- Please complete this template before creating pull request. -->\r\n#### What's in this pull request?\r\n<!-- Description about pull request. -->\r\n\r\nProvides a new fallback for `Process` arguments for those instances where we do not own `main` (e.g. Frameworks, Objective-C owns `main.m` or `main.c`, etc.).  This includes a number of platform-specific specializations of a new runtime function `_swift_get_args` and a new thread-safe interface to `Process.unsafeArgv`.\r\n\r\n#### Resolved bug number: ([SR-1119](https://bugs.swift.org/browse/SR-1119))\r\n<!-- If this pull request resolves any bugs from Swift bug tracker -->\r\n\r\n* * * *\r\n\r\n<!-- This selection should only be completed by Swift admin -->\r\nBefore merging this pull request to apple/swift repository:\r\n- [ ] Test pull request on Swift continuous integration.\r\n\r\n<details>\r\n  <summary>Triggering Swift CI</summary>\r\n\r\nThe swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:\r\n\r\n**Smoke Testing**\r\n\r\n        Platform     | Comment\r\n        ------------ | -------------\r\n        All supported platforms     | @swift-ci Please smoke test\r\n        All supported platforms     | @swift-ci Please smoke test and merge\r\n        OS X platform               | @swift-ci Please smoke test OS X platform\r\n        Linux platform              | @swift-ci Please smoke test Linux platform\r\n\r\n**Validation Testing**\r\n\r\n        Platform     | Comment\r\n        ------------ | -------------\r\n        All supported platforms     | @swift-ci Please test\r\n        All supported platforms     | @swift-ci Please test and merge\r\n        OS X platform               | @swift-ci Please test OS X platform\r\n        OS X platform               | @swift-ci Please benchmark\r\n        Linux platform              | @swift-ci Please test Linux platform\r\n\r\n\r\n**Lint Testing**\r\n\r\n        Language     | Comment\r\n        ------------ | -------------\r\n        Python       | @swift-ci Please Python lint\r\n\r\nNote: Only members of the Apple organization can trigger swift-ci.\r\n</details>\r\n<!-- Thank you for your contribution to Swift! -->\r\n","created_at":"2016-06-21T19:08:34Z","updated_at":"2016-06-21T22:13:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bbdd3119f6e5d28d41a410b23639c7ab319ab095","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift/pulls/3108/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/3108/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/3108/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/0f1b64bc7188356c9a299f347fdbf78a2994788f","head":{"label":"CodaFi:argumental","ref":"argumental","sha":"0f1b64bc7188356c9a299f347fdbf78a2994788f","user":{"login":"CodaFi","id":1896383,"avatar_url":"https://avatars.githubusercontent.com/u/1896383?v=3","gravatar_id":"","url":"https://api.github.com/users/CodaFi","html_url":"https://github.com/CodaFi","followers_url":"https://api.github.com/users/CodaFi/followers","following_url":"https://api.github.com/users/CodaFi/following{/other_user}","gists_url":"https://api.github.com/users/CodaFi/gists{/gist_id}","starred_url":"https://api.github.com/users/CodaFi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CodaFi/subscriptions","organizations_url":"https://api.github.com/users/CodaFi/orgs","repos_url":"https://api.github.com/users/CodaFi/repos","events_url":"https://api.github.com/users/CodaFi/events{/privacy}","received_events_url":"https://api.github.com/users/CodaFi/received_events","type":"User","site_admin":false},"repo":{"id":47345791,"name":"swift","full_name":"CodaFi/swift","owner":{"login":"CodaFi","id":1896383,"avatar_url":"https://avatars.githubusercontent.com/u/1896383?v=3","gravatar_id":"","url":"https://api.github.com/users/CodaFi","html_url":"https://github.com/CodaFi","followers_url":"https://api.github.com/users/CodaFi/followers","following_url":"https://api.github.com/users/CodaFi/following{/other_user}","gists_url":"https://api.github.com/users/CodaFi/gists{/gist_id}","starred_url":"https://api.github.com/users/CodaFi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CodaFi/subscriptions","organizations_url":"https://api.github.com/users/CodaFi/orgs","repos_url":"https://api.github.com/users/CodaFi/repos","events_url":"https://api.github.com/users/CodaFi/events{/privacy}","received_events_url":"https://api.github.com/users/CodaFi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/CodaFi/swift","description":"The Swift Programming Language","fork":true,"url":"https://api.github.com/repos/CodaFi/swift","forks_url":"https://api.github.com/repos/CodaFi/swift/forks","keys_url":"https://api.github.com/repos/CodaFi/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CodaFi/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CodaFi/swift/teams","hooks_url":"https://api.github.com/repos/CodaFi/swift/hooks","issue_events_url":"https://api.github.com/repos/CodaFi/swift/issues/events{/number}","events_url":"https://api.github.com/repos/CodaFi/swift/events","assignees_url":"https://api.github.com/repos/CodaFi/swift/assignees{/user}","branches_url":"https://api.github.com/repos/CodaFi/swift/branches{/branch}","tags_url":"https://api.github.com/repos/CodaFi/swift/tags","blobs_url":"https://api.github.com/repos/CodaFi/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CodaFi/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CodaFi/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/CodaFi/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CodaFi/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/CodaFi/swift/languages","stargazers_url":"https://api.github.com/repos/CodaFi/swift/stargazers","contributors_url":"https://api.github.com/repos/CodaFi/swift/contributors","subscribers_url":"https://api.github.com/repos/CodaFi/swift/subscribers","subscription_url":"https://api.github.com/repos/CodaFi/swift/subscription","commits_url":"https://api.github.com/repos/CodaFi/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/CodaFi/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/CodaFi/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/CodaFi/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/CodaFi/swift/contents/{+path}","compare_url":"https://api.github.com/repos/CodaFi/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CodaFi/swift/merges","archive_url":"https://api.github.com/repos/CodaFi/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CodaFi/swift/downloads","issues_url":"https://api.github.com/repos/CodaFi/swift/issues{/number}","pulls_url":"https://api.github.com/repos/CodaFi/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/CodaFi/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/CodaFi/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CodaFi/swift/labels{/name}","releases_url":"https://api.github.com/repos/CodaFi/swift/releases{/id}","deployments_url":"https://api.github.com/repos/CodaFi/swift/deployments","created_at":"2015-12-03T16:45:39Z","updated_at":"2016-06-13T08:57:12Z","pushed_at":"2016-06-21T22:12:18Z","git_url":"git://github.com/CodaFi/swift.git","ssh_url":"git@github.com:CodaFi/swift.git","clone_url":"https://github.com/CodaFi/swift.git","svn_url":"https://github.com/CodaFi/swift","homepage":"","size":98585,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"864bb61e936c9a847bbc2d0f40e097213656cd83","user":{"login":"apple","id":10639145,"avatar_url":"https://avatars.githubusercontent.com/u/10639145?v=3","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,"name":"swift","full_name":"apple/swift","owner":{"login":"apple","id":10639145,"avatar_url":"https://avatars.githubusercontent.com/u/10639145?v=3","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":"2016-06-21T21:32:52Z","pushed_at":"2016-06-21T22:13:12Z","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":155339,"stargazers_count":31721,"watchers_count":31721,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4332,"mirror_url":null,"open_issues_count":106,"forks":4332,"open_issues":106,"watchers":31721,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/3108"},"html":{"href":"https://github.com/apple/swift/pull/3108"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/3108"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/3108/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/3108/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/3108/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/0f1b64bc7188356c9a299f347fdbf78a2994788f"}}}}
{"actor":{"display_login":"gribozavr"}}