{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corert/pulls/comments/91802820","pull_request_review_id":12316203,"id":91802820,"diff_hunk":"@@ -424,6 +433,22 @@ internal bool Remove(TKey key)\n             }\n \n             //----------------------------------------------------------------------------------------\n+            // Removes all entries from the table.\n+            //\n+            // Precondition:\n+            //      Must hold _lock.\n+            //----------------------------------------------------------------------------------------\n+            internal void Clear()\n+            {\n+                // Remove all handles (as in Remove, just by setting the hashcode and leaving\n+                // actual removal up to the finalizer).\n+                for (int i = 0; i < _firstFreeEntry; i++)","path":"src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs","position":63,"original_position":63,"commit_id":"952122da9890681faff89ff2b3ec0ec70cc90217","original_commit_id":"952122da9890681faff89ff2b3ec0ec70cc90217","user":{"login":"jkotas","id":6668460,"avatar_url":"https://avatars.githubusercontent.com/u/6668460?v=3","gravatar_id":"","url":"https://api.github.com/users/jkotas","html_url":"https://github.com/jkotas","followers_url":"https://api.github.com/users/jkotas/followers","following_url":"https://api.github.com/users/jkotas/following{/other_user}","gists_url":"https://api.github.com/users/jkotas/gists{/gist_id}","starred_url":"https://api.github.com/users/jkotas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkotas/subscriptions","organizations_url":"https://api.github.com/users/jkotas/orgs","repos_url":"https://api.github.com/users/jkotas/repos","events_url":"https://api.github.com/users/jkotas/events{/privacy}","received_events_url":"https://api.github.com/users/jkotas/received_events","type":"User","site_admin":false},"body":"The handles will be still active and keeping the dependent objects alive, until the next rehash happens. It may take a long time, or potentially forever. We should also set the primary to null or something. Was the same problem in the original CoreCLR implementation?","created_at":"2016-12-09T21:52:34Z","updated_at":"2016-12-09T21:52:34Z","html_url":"https://github.com/dotnet/corert/pull/2322#discussion_r91802820","pull_request_url":"https://api.github.com/repos/dotnet/corert/pulls/2322","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corert/pulls/comments/91802820"},"html":{"href":"https://github.com/dotnet/corert/pull/2322#discussion_r91802820"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corert/pulls/2322"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corert/pulls/2322","id":97379044,"html_url":"https://github.com/dotnet/corert/pull/2322","diff_url":"https://github.com/dotnet/corert/pull/2322.diff","patch_url":"https://github.com/dotnet/corert/pull/2322.patch","issue_url":"https://api.github.com/repos/dotnet/corert/issues/2322","number":2322,"state":"open","locked":false,"title":"Port fixes to ConditionalWeakTable","user":{"login":"stephentoub","id":2642209,"avatar_url":"https://avatars.githubusercontent.com/u/2642209?v=3","gravatar_id":"","url":"https://api.github.com/users/stephentoub","html_url":"https://github.com/stephentoub","followers_url":"https://api.github.com/users/stephentoub/followers","following_url":"https://api.github.com/users/stephentoub/following{/other_user}","gists_url":"https://api.github.com/users/stephentoub/gists{/gist_id}","starred_url":"https://api.github.com/users/stephentoub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephentoub/subscriptions","organizations_url":"https://api.github.com/users/stephentoub/orgs","repos_url":"https://api.github.com/users/stephentoub/repos","events_url":"https://api.github.com/users/stephentoub/events{/privacy}","received_events_url":"https://api.github.com/users/stephentoub/received_events","type":"User","site_admin":false},"body":"CoreRT's ConditionalWeakTable implementation was ported to CoreCLR in https://github.com/dotnet/coreclr/pull/8507.  In the process, several fixes were made; this ports those fixes back.\r\n\r\nTwo issues addressed:\r\n- Every time the table resizes, it ends up allocating a new dependency handle for every handle in the table.  That's not cheap.  Instead, we now transfer still valid handles from the old container to the new container, giving the new container the responsibility of freeing them when it's finalized... and the old container keeps it alive as long as the old container is alive via a reference.\r\n- There's a race condition present whereby if a ConditionalWeakTable is resurrected, it's possible for a thread to try accessing a dependency handle while or after it's been freed.  This is addressed by not freeing during the first finalization, instead using that pass to clear out the table's reference to the container and then re-registering for finalization: the next time it's finalized, we can be sure it won't get resurrected and there won't be a race condition.\r\n\r\ncc: @jkotas, @mjp41 ","created_at":"2016-12-09T20:58:26Z","updated_at":"2016-12-09T21:52:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9fddedf0f850bbd65597faece8634de327a1eaa0","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corert/pulls/2322/commits","review_comments_url":"https://api.github.com/repos/dotnet/corert/pulls/2322/comments","review_comment_url":"https://api.github.com/repos/dotnet/corert/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corert/issues/2322/comments","statuses_url":"https://api.github.com/repos/dotnet/corert/statuses/952122da9890681faff89ff2b3ec0ec70cc90217","head":{"label":"stephentoub:port8507","ref":"port8507","sha":"952122da9890681faff89ff2b3ec0ec70cc90217","user":{"login":"stephentoub","id":2642209,"avatar_url":"https://avatars.githubusercontent.com/u/2642209?v=3","gravatar_id":"","url":"https://api.github.com/users/stephentoub","html_url":"https://github.com/stephentoub","followers_url":"https://api.github.com/users/stephentoub/followers","following_url":"https://api.github.com/users/stephentoub/following{/other_user}","gists_url":"https://api.github.com/users/stephentoub/gists{/gist_id}","starred_url":"https://api.github.com/users/stephentoub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephentoub/subscriptions","organizations_url":"https://api.github.com/users/stephentoub/orgs","repos_url":"https://api.github.com/users/stephentoub/repos","events_url":"https://api.github.com/users/stephentoub/events{/privacy}","received_events_url":"https://api.github.com/users/stephentoub/received_events","type":"User","site_admin":false},"repo":{"id":46594407,"name":"corert","full_name":"stephentoub/corert","owner":{"login":"stephentoub","id":2642209,"avatar_url":"https://avatars.githubusercontent.com/u/2642209?v=3","gravatar_id":"","url":"https://api.github.com/users/stephentoub","html_url":"https://github.com/stephentoub","followers_url":"https://api.github.com/users/stephentoub/followers","following_url":"https://api.github.com/users/stephentoub/following{/other_user}","gists_url":"https://api.github.com/users/stephentoub/gists{/gist_id}","starred_url":"https://api.github.com/users/stephentoub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephentoub/subscriptions","organizations_url":"https://api.github.com/users/stephentoub/orgs","repos_url":"https://api.github.com/users/stephentoub/repos","events_url":"https://api.github.com/users/stephentoub/events{/privacy}","received_events_url":"https://api.github.com/users/stephentoub/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/stephentoub/corert","description":"This repo contains CoreRT, a .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying .NET Native compiler toolchain.","fork":true,"url":"https://api.github.com/repos/stephentoub/corert","forks_url":"https://api.github.com/repos/stephentoub/corert/forks","keys_url":"https://api.github.com/repos/stephentoub/corert/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stephentoub/corert/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stephentoub/corert/teams","hooks_url":"https://api.github.com/repos/stephentoub/corert/hooks","issue_events_url":"https://api.github.com/repos/stephentoub/corert/issues/events{/number}","events_url":"https://api.github.com/repos/stephentoub/corert/events","assignees_url":"https://api.github.com/repos/stephentoub/corert/assignees{/user}","branches_url":"https://api.github.com/repos/stephentoub/corert/branches{/branch}","tags_url":"https://api.github.com/repos/stephentoub/corert/tags","blobs_url":"https://api.github.com/repos/stephentoub/corert/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stephentoub/corert/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stephentoub/corert/git/refs{/sha}","trees_url":"https://api.github.com/repos/stephentoub/corert/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stephentoub/corert/statuses/{sha}","languages_url":"https://api.github.com/repos/stephentoub/corert/languages","stargazers_url":"https://api.github.com/repos/stephentoub/corert/stargazers","contributors_url":"https://api.github.com/repos/stephentoub/corert/contributors","subscribers_url":"https://api.github.com/repos/stephentoub/corert/subscribers","subscription_url":"https://api.github.com/repos/stephentoub/corert/subscription","commits_url":"https://api.github.com/repos/stephentoub/corert/commits{/sha}","git_commits_url":"https://api.github.com/repos/stephentoub/corert/git/commits{/sha}","comments_url":"https://api.github.com/repos/stephentoub/corert/comments{/number}","issue_comment_url":"https://api.github.com/repos/stephentoub/corert/issues/comments{/number}","contents_url":"https://api.github.com/repos/stephentoub/corert/contents/{+path}","compare_url":"https://api.github.com/repos/stephentoub/corert/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stephentoub/corert/merges","archive_url":"https://api.github.com/repos/stephentoub/corert/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stephentoub/corert/downloads","issues_url":"https://api.github.com/repos/stephentoub/corert/issues{/number}","pulls_url":"https://api.github.com/repos/stephentoub/corert/pulls{/number}","milestones_url":"https://api.github.com/repos/stephentoub/corert/milestones{/number}","notifications_url":"https://api.github.com/repos/stephentoub/corert/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stephentoub/corert/labels{/name}","releases_url":"https://api.github.com/repos/stephentoub/corert/releases{/id}","deployments_url":"https://api.github.com/repos/stephentoub/corert/deployments","created_at":"2015-11-21T00:30:22Z","updated_at":"2016-01-14T02:34:28Z","pushed_at":"2016-12-09T20:55:42Z","git_url":"git://github.com/stephentoub/corert.git","ssh_url":"git@github.com:stephentoub/corert.git","clone_url":"https://github.com/stephentoub/corert.git","svn_url":"https://github.com/stephentoub/corert","homepage":"http://dotnet.github.io/","size":12784,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"1df23a250632f186dca9841d13d57432e3b25355","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":42552143,"name":"corert","full_name":"dotnet/corert","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/corert","description":"This repo contains CoreRT, a .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying .NET Native compiler toolchain.","fork":false,"url":"https://api.github.com/repos/dotnet/corert","forks_url":"https://api.github.com/repos/dotnet/corert/forks","keys_url":"https://api.github.com/repos/dotnet/corert/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corert/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corert/teams","hooks_url":"https://api.github.com/repos/dotnet/corert/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corert/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corert/events","assignees_url":"https://api.github.com/repos/dotnet/corert/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corert/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corert/tags","blobs_url":"https://api.github.com/repos/dotnet/corert/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corert/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corert/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corert/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corert/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corert/languages","stargazers_url":"https://api.github.com/repos/dotnet/corert/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corert/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corert/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corert/subscription","commits_url":"https://api.github.com/repos/dotnet/corert/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corert/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corert/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corert/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corert/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corert/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corert/merges","archive_url":"https://api.github.com/repos/dotnet/corert/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corert/downloads","issues_url":"https://api.github.com/repos/dotnet/corert/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corert/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corert/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corert/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corert/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corert/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/corert/deployments","created_at":"2015-09-15T23:10:53Z","updated_at":"2016-12-08T23:32:09Z","pushed_at":"2016-12-09T21:34:37Z","git_url":"git://github.com/dotnet/corert.git","ssh_url":"git@github.com:dotnet/corert.git","clone_url":"https://github.com/dotnet/corert.git","svn_url":"https://github.com/dotnet/corert","homepage":"http://dotnet.github.io/","size":22440,"stargazers_count":494,"watchers_count":494,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":160,"mirror_url":null,"open_issues_count":176,"forks":160,"open_issues":176,"watchers":494,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corert/pulls/2322"},"html":{"href":"https://github.com/dotnet/corert/pull/2322"},"issue":{"href":"https://api.github.com/repos/dotnet/corert/issues/2322"},"comments":{"href":"https://api.github.com/repos/dotnet/corert/issues/2322/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corert/pulls/2322/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corert/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corert/pulls/2322/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corert/statuses/952122da9890681faff89ff2b3ec0ec70cc90217"}}}}
{"actor":{"display_login":"jkotas"}}