{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/245461571","pull_request_review_id":189579183,"id":245461571,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NTQ2MTU3MQ==","diff_hunk":"@@ -54,35 +54,65 @@ bool EventPipeBuffer::WriteEvent(Thread *pThread, EventPipeSession &session, Eve\n         NOTHROW;\n         GC_NOTRIGGER;\n         MODE_ANY;\n-        PRECONDITION(pThread != NULL);\n         PRECONDITION(((size_t)m_pCurrent % AlignmentSize) == 0);\n     }\n     CONTRACTL_END;\n \n     // Calculate the size of the event.\n     unsigned int eventSize = sizeof(EventPipeEventInstance) + payload.GetSize();\n+    DWORD osThreadId;\n \n     // Make sure we have enough space to write the event.\n     if(m_pCurrent + eventSize >= m_pLimit)\n     {\n         return false;\n     }\n \n+    if (pThread == NULL)\n+    {\n+        // For ThreadID just get the Current Thread ID\n+        osThreadId = ::GetCurrentThreadId();\n+    }\n+    else\n+    {\n+        osThreadId = pThread->GetOSThreadId();\n+    }\n+\n     // Calculate the location of the data payload.\n     BYTE *pDataDest = m_pCurrent + sizeof(EventPipeEventInstance);\n+    EventPipeEventInstance *pInstance;\n \n     bool success = true;\n     EX_TRY\n     {\n+        LPCGUID pThreadActivityID = pActivityId;\n+\n         // Placement-new the EventPipeEventInstance.\n-        EventPipeEventInstance *pInstance = new (m_pCurrent) EventPipeEventInstance(\n-            session,\n-            event,\n-            pThread->GetOSThreadId(),\n-            pDataDest,\n-            payload.GetSize(),\n-            pActivityId,\n-            pRelatedActivityId);\n+\n+        if (pThread == NULL)\n+        {\n+            // if pthread is NULL, it's likely we are running in something like a GC thread which is not a Thread object, so it can't have an activity ID set anyway\n+            pInstance = new (m_pCurrent) EventPipeEventInstance(","path":"src/vm/eventpipebuffer.cpp","position":51,"original_position":51,"commit_id":"662f9c0e35fbce5cd32277ddc38f55c4d290d896","original_commit_id":"662f9c0e35fbce5cd32277ddc38f55c4d290d896","user":{"login":"jkotas","id":6668460,"node_id":"MDQ6VXNlcjY2Njg0NjA=","avatar_url":"https://avatars2.githubusercontent.com/u/6668460?v=4","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 only thing thing different between the two cases is the activity ID argument. You can just have the condition for that one argument without duplicating the whole thing.\r\n\r\n`(pThread != NULL) ? pActivityId : NULL`","created_at":"2019-01-05T01:42:18Z","updated_at":"2019-01-05T01:42:18Z","html_url":"https://github.com/dotnet/coreclr/pull/21817#discussion_r245461571","pull_request_url":"https://api.github.com/repos/dotnet/coreclr/pulls/21817","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/245461571"},"html":{"href":"https://github.com/dotnet/coreclr/pull/21817#discussion_r245461571"},"pull_request":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/21817"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/21817","id":242400665,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQyNDAwNjY1","html_url":"https://github.com/dotnet/coreclr/pull/21817","diff_url":"https://github.com/dotnet/coreclr/pull/21817.diff","patch_url":"https://github.com/dotnet/coreclr/pull/21817.patch","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/21817","number":21817,"state":"open","locked":false,"title":"Move eventpipe buffer to TLS","user":{"login":"sywhang","id":30421794,"node_id":"MDQ6VXNlcjMwNDIxNzk0","avatar_url":"https://avatars0.githubusercontent.com/u/30421794?v=4","gravatar_id":"","url":"https://api.github.com/users/sywhang","html_url":"https://github.com/sywhang","followers_url":"https://api.github.com/users/sywhang/followers","following_url":"https://api.github.com/users/sywhang/following{/other_user}","gists_url":"https://api.github.com/users/sywhang/gists{/gist_id}","starred_url":"https://api.github.com/users/sywhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sywhang/subscriptions","organizations_url":"https://api.github.com/users/sywhang/orgs","repos_url":"https://api.github.com/users/sywhang/repos","events_url":"https://api.github.com/users/sywhang/events{/privacy}","received_events_url":"https://api.github.com/users/sywhang/received_events","type":"User","site_admin":false},"body":"EventPipe has a buffer that's stored in the ```Thread``` object, but in the runtime we may be emitting events from threads that are not ```Thread``` object. (i.e. BGC threads). This moves the pointer to ```EventPipeBufferList``` that's stored in Thread to TLS so that it can be accessed from a \"non-Thread\" thread.\r\n\r\nThis should address https://github.com/dotnet/coreclr/issues/21380","created_at":"2019-01-04T23:41:46Z","updated_at":"2019-01-05T01:42:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9f157abc0ff50f934ca1075db483eaf8a2f134d8","assignee":null,"assignees":[],"requested_reviewers":[{"login":"noahfalk","id":6243776,"node_id":"MDQ6VXNlcjYyNDM3NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/6243776?v=4","gravatar_id":"","url":"https://api.github.com/users/noahfalk","html_url":"https://github.com/noahfalk","followers_url":"https://api.github.com/users/noahfalk/followers","following_url":"https://api.github.com/users/noahfalk/following{/other_user}","gists_url":"https://api.github.com/users/noahfalk/gists{/gist_id}","starred_url":"https://api.github.com/users/noahfalk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noahfalk/subscriptions","organizations_url":"https://api.github.com/users/noahfalk/orgs","repos_url":"https://api.github.com/users/noahfalk/repos","events_url":"https://api.github.com/users/noahfalk/events{/privacy}","received_events_url":"https://api.github.com/users/noahfalk/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/coreclr/pulls/21817/commits","review_comments_url":"https://api.github.com/repos/dotnet/coreclr/pulls/21817/comments","review_comment_url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/21817/comments","statuses_url":"https://api.github.com/repos/dotnet/coreclr/statuses/662f9c0e35fbce5cd32277ddc38f55c4d290d896","head":{"label":"sywhang:fix-eventpipe-buffer","ref":"fix-eventpipe-buffer","sha":"662f9c0e35fbce5cd32277ddc38f55c4d290d896","user":{"login":"sywhang","id":30421794,"node_id":"MDQ6VXNlcjMwNDIxNzk0","avatar_url":"https://avatars0.githubusercontent.com/u/30421794?v=4","gravatar_id":"","url":"https://api.github.com/users/sywhang","html_url":"https://github.com/sywhang","followers_url":"https://api.github.com/users/sywhang/followers","following_url":"https://api.github.com/users/sywhang/following{/other_user}","gists_url":"https://api.github.com/users/sywhang/gists{/gist_id}","starred_url":"https://api.github.com/users/sywhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sywhang/subscriptions","organizations_url":"https://api.github.com/users/sywhang/orgs","repos_url":"https://api.github.com/users/sywhang/repos","events_url":"https://api.github.com/users/sywhang/events{/privacy}","received_events_url":"https://api.github.com/users/sywhang/received_events","type":"User","site_admin":false},"repo":{"id":98243814,"node_id":"MDEwOlJlcG9zaXRvcnk5ODI0MzgxNA==","name":"coreclr","full_name":"sywhang/coreclr","private":false,"owner":{"login":"sywhang","id":30421794,"node_id":"MDQ6VXNlcjMwNDIxNzk0","avatar_url":"https://avatars0.githubusercontent.com/u/30421794?v=4","gravatar_id":"","url":"https://api.github.com/users/sywhang","html_url":"https://github.com/sywhang","followers_url":"https://api.github.com/users/sywhang/followers","following_url":"https://api.github.com/users/sywhang/following{/other_user}","gists_url":"https://api.github.com/users/sywhang/gists{/gist_id}","starred_url":"https://api.github.com/users/sywhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sywhang/subscriptions","organizations_url":"https://api.github.com/users/sywhang/orgs","repos_url":"https://api.github.com/users/sywhang/repos","events_url":"https://api.github.com/users/sywhang/events{/privacy}","received_events_url":"https://api.github.com/users/sywhang/received_events","type":"User","site_admin":false},"html_url":"https://github.com/sywhang/coreclr","description":"This repo contains the .NET Core runtime, called CoreCLR, and the base library, called mscorlib. It includes the garbage collector, JIT compiler, base .NET data types and many low-level classes. We welcome contributions.","fork":true,"url":"https://api.github.com/repos/sywhang/coreclr","forks_url":"https://api.github.com/repos/sywhang/coreclr/forks","keys_url":"https://api.github.com/repos/sywhang/coreclr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sywhang/coreclr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sywhang/coreclr/teams","hooks_url":"https://api.github.com/repos/sywhang/coreclr/hooks","issue_events_url":"https://api.github.com/repos/sywhang/coreclr/issues/events{/number}","events_url":"https://api.github.com/repos/sywhang/coreclr/events","assignees_url":"https://api.github.com/repos/sywhang/coreclr/assignees{/user}","branches_url":"https://api.github.com/repos/sywhang/coreclr/branches{/branch}","tags_url":"https://api.github.com/repos/sywhang/coreclr/tags","blobs_url":"https://api.github.com/repos/sywhang/coreclr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sywhang/coreclr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sywhang/coreclr/git/refs{/sha}","trees_url":"https://api.github.com/repos/sywhang/coreclr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sywhang/coreclr/statuses/{sha}","languages_url":"https://api.github.com/repos/sywhang/coreclr/languages","stargazers_url":"https://api.github.com/repos/sywhang/coreclr/stargazers","contributors_url":"https://api.github.com/repos/sywhang/coreclr/contributors","subscribers_url":"https://api.github.com/repos/sywhang/coreclr/subscribers","subscription_url":"https://api.github.com/repos/sywhang/coreclr/subscription","commits_url":"https://api.github.com/repos/sywhang/coreclr/commits{/sha}","git_commits_url":"https://api.github.com/repos/sywhang/coreclr/git/commits{/sha}","comments_url":"https://api.github.com/repos/sywhang/coreclr/comments{/number}","issue_comment_url":"https://api.github.com/repos/sywhang/coreclr/issues/comments{/number}","contents_url":"https://api.github.com/repos/sywhang/coreclr/contents/{+path}","compare_url":"https://api.github.com/repos/sywhang/coreclr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sywhang/coreclr/merges","archive_url":"https://api.github.com/repos/sywhang/coreclr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sywhang/coreclr/downloads","issues_url":"https://api.github.com/repos/sywhang/coreclr/issues{/number}","pulls_url":"https://api.github.com/repos/sywhang/coreclr/pulls{/number}","milestones_url":"https://api.github.com/repos/sywhang/coreclr/milestones{/number}","notifications_url":"https://api.github.com/repos/sywhang/coreclr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sywhang/coreclr/labels{/name}","releases_url":"https://api.github.com/repos/sywhang/coreclr/releases{/id}","deployments_url":"https://api.github.com/repos/sywhang/coreclr/deployments","created_at":"2017-07-24T23:37:12Z","updated_at":"2019-01-04T16:29:17Z","pushed_at":"2019-01-04T23:37:59Z","git_url":"git://github.com/sywhang/coreclr.git","ssh_url":"git@github.com:sywhang/coreclr.git","clone_url":"https://github.com/sywhang/coreclr.git","svn_url":"https://github.com/sywhang/coreclr","homepage":"https://github.com/dotnet/core","size":261030,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"83bd6ca494971c399b3fbebee4623d9bf294731d","user":{"login":"dotnet","id":9141961,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDE5NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","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":30092893,"node_id":"MDEwOlJlcG9zaXRvcnkzMDA5Mjg5Mw==","name":"coreclr","full_name":"dotnet/coreclr","private":false,"owner":{"login":"dotnet","id":9141961,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDE5NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","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},"html_url":"https://github.com/dotnet/coreclr","description":"CoreCLR is the runtime for .NET Core. It includes the garbage collector, JIT compiler, primitive data types and low-level classes.","fork":false,"url":"https://api.github.com/repos/dotnet/coreclr","forks_url":"https://api.github.com/repos/dotnet/coreclr/forks","keys_url":"https://api.github.com/repos/dotnet/coreclr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/coreclr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/coreclr/teams","hooks_url":"https://api.github.com/repos/dotnet/coreclr/hooks","issue_events_url":"https://api.github.com/repos/dotnet/coreclr/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/coreclr/events","assignees_url":"https://api.github.com/repos/dotnet/coreclr/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/coreclr/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/coreclr/tags","blobs_url":"https://api.github.com/repos/dotnet/coreclr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/coreclr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/coreclr/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/coreclr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/coreclr/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/coreclr/languages","stargazers_url":"https://api.github.com/repos/dotnet/coreclr/stargazers","contributors_url":"https://api.github.com/repos/dotnet/coreclr/contributors","subscribers_url":"https://api.github.com/repos/dotnet/coreclr/subscribers","subscription_url":"https://api.github.com/repos/dotnet/coreclr/subscription","commits_url":"https://api.github.com/repos/dotnet/coreclr/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/coreclr/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/coreclr/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/coreclr/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/coreclr/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/coreclr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/coreclr/merges","archive_url":"https://api.github.com/repos/dotnet/coreclr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/coreclr/downloads","issues_url":"https://api.github.com/repos/dotnet/coreclr/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/coreclr/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/coreclr/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/coreclr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/coreclr/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/coreclr/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/coreclr/deployments","created_at":"2015-01-30T22:10:02Z","updated_at":"2019-01-05T00:45:24Z","pushed_at":"2019-01-05T01:19:56Z","git_url":"git://github.com/dotnet/coreclr.git","ssh_url":"git@github.com:dotnet/coreclr.git","clone_url":"https://github.com/dotnet/coreclr.git","svn_url":"https://github.com/dotnet/coreclr","homepage":"https://docs.microsoft.com/dotnet/core/","size":301863,"stargazers_count":10768,"watchers_count":10768,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2559,"mirror_url":null,"archived":false,"open_issues_count":2095,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2559,"open_issues":2095,"watchers":10768,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/21817"},"html":{"href":"https://github.com/dotnet/coreclr/pull/21817"},"issue":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/21817"},"comments":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/21817/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/21817/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/21817/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/coreclr/statuses/662f9c0e35fbce5cd32277ddc38f55c4d290d896"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"jkotas"}}