|
|
Created:
4 years, 11 months ago by Anand Mistry (off Chromium) Modified:
4 years, 11 months ago CC:
chromium-reviews, loading-reviews_chromium.org, darin-cc_chromium.org, jam, chrome-apps-syd-reviews_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionPost a task to the IO thread to add a ResourceContext in ResourceDispatcherHostImpl.
ResourceDispatcherHostImpl::AddResourceContext() is called on the UI thread,
but all other users of |active_resource_contexts_| access it on the IO thread.
Committed: https://crrev.com/3f29b4056e85ed6259b679e9858134422caaf72f
Cr-Commit-Position: refs/heads/master@{#371687}
Patch Set 1 #Patch Set 2 : Post task instead of using lock. #Patch Set 3 : Move task posting to call site. #
Total comments: 2
Patch Set 4 : Rebase #
Messages
Total messages: 35 (12 generated)
amistry@chromium.org changed reviewers: + mmenke@chromium.org
I found this using tsan. It was happening when an incognito profile was being created. I've lost the tsan output, but inspecting the profile code suggests this can happen in Chrome when either: 1. An incognito window is created 2. A new profile is created
On 2016/01/18 23:28:05, Anand Mistry wrote: > I found this using tsan. It was happening when an incognito profile was being > created. I've lost the tsan output, but inspecting the profile code suggests > this can happen in Chrome when either: > 1. An incognito window is created > 2. A new profile is created Thanks for catching this! It looks like |active_resource_contexts_| was only added to investigate https://crbug.com/90971, which has since been marked as fixed. I think it makes more sense to just remove this code, and the code that calls ResourceDispatcherHostImpl::AddResourceContext.
On 2016/01/19 16:55:57, mmenke wrote: > On 2016/01/18 23:28:05, Anand Mistry wrote: > > I found this using tsan. It was happening when an incognito profile was being > > created. I've lost the tsan output, but inspecting the profile code suggests > > this can happen in Chrome when either: > > 1. An incognito window is created > > 2. A new profile is created > > Thanks for catching this! > > It looks like |active_resource_contexts_| was only added to investigate > https://crbug.com/90971, which has since been marked as fixed. I think it makes > more sense to just remove this code, and the code that calls > ResourceDispatcherHostImpl::AddResourceContext. I took a look at crash reports. These CHECKs are still triggering on M49. Presumably there's still value in keeping these around. As for the bug, it looks like it's to add the CHECKs to catch a certain class of bugs. Removing these would un-fix the bug, so to speak.
On 2016/01/19 23:03:22, Anand Mistry wrote: > On 2016/01/19 16:55:57, mmenke wrote: > > On 2016/01/18 23:28:05, Anand Mistry wrote: > > > I found this using tsan. It was happening when an incognito profile was > being > > > created. I've lost the tsan output, but inspecting the profile code suggests > > > this can happen in Chrome when either: > > > 1. An incognito window is created > > > 2. A new profile is created > > > > Thanks for catching this! > > > > It looks like |active_resource_contexts_| was only added to investigate > > https://crbug.com/90971, which has since been marked as fixed. I think it > makes > > more sense to just remove this code, and the code that calls > > ResourceDispatcherHostImpl::AddResourceContext. > > I took a look at crash reports. These CHECKs are still triggering on M49. > Presumably there's still value in keeping these around. > > As for the bug, it looks like it's to add the CHECKs to catch a certain class of > bugs. Removing these would un-fix the bug, so to speak. Ah, right...These are mostly cases where we receive messages from process that have had their RenderViewHosts destroyed, because the filter code is refcounted. Not an RDH bug, but real issues. I think it makes more sense to have ResourceContext::ResourceContext() post task over to the IO thread, rather than to use locks (The destructor must be called on the IO thread, so no changes needed there)
On 2016/01/19 23:25:14, mmenke wrote: > On 2016/01/19 23:03:22, Anand Mistry wrote: > > On 2016/01/19 16:55:57, mmenke wrote: > > > On 2016/01/18 23:28:05, Anand Mistry wrote: > > > > I found this using tsan. It was happening when an incognito profile was > > being > > > > created. I've lost the tsan output, but inspecting the profile code > suggests > > > > this can happen in Chrome when either: > > > > 1. An incognito window is created > > > > 2. A new profile is created > > > > > > Thanks for catching this! > > > > > > It looks like |active_resource_contexts_| was only added to investigate > > > https://crbug.com/90971, which has since been marked as fixed. I think it > > makes > > > more sense to just remove this code, and the code that calls > > > ResourceDispatcherHostImpl::AddResourceContext. > > > > I took a look at crash reports. These CHECKs are still triggering on M49. > > Presumably there's still value in keeping these around. > > > > As for the bug, it looks like it's to add the CHECKs to catch a certain class > of > > bugs. Removing these would un-fix the bug, so to speak. > > Ah, right...These are mostly cases where we receive messages from process that > have had their RenderViewHosts destroyed, because the filter code is refcounted. > Not an RDH bug, but real issues. > > I think it makes more sense to have ResourceContext::ResourceContext() post task > over to the IO thread, rather than to use locks (The destructor must be called > on the IO thread, so no changes needed there) According to the comment in ~ResourceContext, tests can destroy it on the UI thread. Oh tests. But as for the constructor, my concern is that there could be an ordering issue if you post to the IO thread. Even though posted tasks are ordered, there might be a case where a ResourceContext is destroyed before the added task gets a chance to run. I can't think of any specific case, but that's my concern. And if you're concerned about performance, this is far cheaper than posting a task.
On 2016/01/19 23:41:54, Anand Mistry wrote: > On 2016/01/19 23:25:14, mmenke wrote: > > On 2016/01/19 23:03:22, Anand Mistry wrote: > > > On 2016/01/19 16:55:57, mmenke wrote: > > > > On 2016/01/18 23:28:05, Anand Mistry wrote: > > > > > I found this using tsan. It was happening when an incognito profile was > > > being > > > > > created. I've lost the tsan output, but inspecting the profile code > > suggests > > > > > this can happen in Chrome when either: > > > > > 1. An incognito window is created > > > > > 2. A new profile is created > > > > > > > > Thanks for catching this! > > > > > > > > It looks like |active_resource_contexts_| was only added to investigate > > > > https://crbug.com/90971, which has since been marked as fixed. I think it > > > makes > > > > more sense to just remove this code, and the code that calls > > > > ResourceDispatcherHostImpl::AddResourceContext. > > > > > > I took a look at crash reports. These CHECKs are still triggering on M49. > > > Presumably there's still value in keeping these around. > > > > > > As for the bug, it looks like it's to add the CHECKs to catch a certain > class > > of > > > bugs. Removing these would un-fix the bug, so to speak. > > > > Ah, right...These are mostly cases where we receive messages from process that > > have had their RenderViewHosts destroyed, because the filter code is > refcounted. > > Not an RDH bug, but real issues. > > > > I think it makes more sense to have ResourceContext::ResourceContext() post > task > > over to the IO thread, rather than to use locks (The destructor must be called > > on the IO thread, so no changes needed there) > > According to the comment in ~ResourceContext, tests can destroy it on the UI > thread. Oh tests. > > But as for the constructor, my concern is that there could be an ordering issue > if you post to the IO thread. Even though posted tasks are ordered, there might > be a case where a ResourceContext is destroyed before the added task gets a > chance to run. I can't think of any specific case, but that's my concern. > > And if you're concerned about performance, this is far cheaper than posting a > task. There can't be an ordering issue. You can issue requests for a RequestContext until its been constructed, so it would be impossible for a message about what to do with the RequestContext to make it to the IOThread before the posted task. I'm not concerned about performance, message passing is just preferred in chrome, due to deadlock concerns (Though if I were concerned about performance, we're considering posting a single task on profile startup to grabbing and releasing a lock for every single network request issued by chrome. Even given that obtaining a lock is fairly cheap, and there's never any contention for it, the task seems much cheaper)
Description was changed from ========== Add lock around |ResourceDispatcherHostImpl::active_resource_contexts_|, which can be modified and used on different threads. ========== to ========== Post a task to the IO thread to add a ResourceContext in ResourceDispatcherHostImpl. ResourceDispatcherHostImpl::AddResourceContext() is called on the UI thread, but all other users of |active_resource_contexts_| access it on the IO thread. ==========
Description was changed from ========== Post a task to the IO thread to add a ResourceContext in ResourceDispatcherHostImpl. ResourceDispatcherHostImpl::AddResourceContext() is called on the UI thread, but all other users of |active_resource_contexts_| access it on the IO thread. ========== to ========== Post a task to the IO thread to add a ResourceContext in ResourceDispatcherHostImpl. ResourceDispatcherHostImpl::AddResourceContext() is called on the UI thread, but all other users of |active_resource_contexts_| access it on the IO thread. ==========
On 2016/01/20 00:09:59, mmenke wrote: > On 2016/01/19 23:41:54, Anand Mistry wrote: > > On 2016/01/19 23:25:14, mmenke wrote: > > > On 2016/01/19 23:03:22, Anand Mistry wrote: > > > > On 2016/01/19 16:55:57, mmenke wrote: > > > > > On 2016/01/18 23:28:05, Anand Mistry wrote: > > > > > > I found this using tsan. It was happening when an incognito profile > was > > > > being > > > > > > created. I've lost the tsan output, but inspecting the profile code > > > suggests > > > > > > this can happen in Chrome when either: > > > > > > 1. An incognito window is created > > > > > > 2. A new profile is created > > > > > > > > > > Thanks for catching this! > > > > > > > > > > It looks like |active_resource_contexts_| was only added to investigate > > > > > https://crbug.com/90971, which has since been marked as fixed. I think > it > > > > makes > > > > > more sense to just remove this code, and the code that calls > > > > > ResourceDispatcherHostImpl::AddResourceContext. > > > > > > > > I took a look at crash reports. These CHECKs are still triggering on M49. > > > > Presumably there's still value in keeping these around. > > > > > > > > As for the bug, it looks like it's to add the CHECKs to catch a certain > > class > > > of > > > > bugs. Removing these would un-fix the bug, so to speak. > > > > > > Ah, right...These are mostly cases where we receive messages from process > that > > > have had their RenderViewHosts destroyed, because the filter code is > > refcounted. > > > Not an RDH bug, but real issues. > > > > > > I think it makes more sense to have ResourceContext::ResourceContext() post > > task > > > over to the IO thread, rather than to use locks (The destructor must be > called > > > on the IO thread, so no changes needed there) > > > > According to the comment in ~ResourceContext, tests can destroy it on the UI > > thread. Oh tests. > > > > But as for the constructor, my concern is that there could be an ordering > issue > > if you post to the IO thread. Even though posted tasks are ordered, there > might > > be a case where a ResourceContext is destroyed before the added task gets a > > chance to run. I can't think of any specific case, but that's my concern. > > > > And if you're concerned about performance, this is far cheaper than posting a > > task. > > There can't be an ordering issue. You can issue requests for a RequestContext > until its been constructed, so it would be impossible for a message about what > to do with the RequestContext to make it to the IOThread before the posted task. Thanks for the clarification. > I'm not concerned about performance, message passing is just preferred in > chrome, due to deadlock concerns (Though if I were concerned about performance, > we're considering posting a single task on profile startup to grabbing and > releasing a lock for every single network request issued by chrome. Even given > that obtaining a lock is fairly cheap, and there's never any contention for it, > the task seems much cheaper) Ack. Switched to posting a task. PTAL.
The CQ bit was checked by amistry@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1600263002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1600263002/20001
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_amd64-generic_chromium_compile_only_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_amd64-...) chromeos_x86-generic_chromium_compile_only_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_x86-ge...) linux_chromium_chromeos_ozone_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
Seems to me like the PostTask should really be in ResourceContext::ResourceContext - every other method in RDH (Except the constructor, and maybe the destructor) is IO-thread only. Having one other random method that must be called on the UI thread seems weird.
On 2016/01/20 15:48:03, mmenke wrote: > Seems to me like the PostTask should really be in > ResourceContext::ResourceContext - every other method in RDH (Except the > constructor, and maybe the destructor) is IO-thread only. Having one other > random method that must be called on the UI thread seems weird. Gotcha. PTAL.
LGTM! https://codereview.chromium.org/1600263002/diff/40001/content/browser/loader/... File content/browser/loader/resource_dispatcher_host_impl.cc (right): https://codereview.chromium.org/1600263002/diff/40001/content/browser/loader/... content/browser/loader/resource_dispatcher_host_impl.cc:546: DCHECK_CURRENTLY_ON(BrowserThread::IO); May want to add a DCHECK to RemoveResourceContext as well, just for documentation purposes (And out of paranoia)
https://codereview.chromium.org/1600263002/diff/40001/content/browser/loader/... File content/browser/loader/resource_dispatcher_host_impl.cc (right): https://codereview.chromium.org/1600263002/diff/40001/content/browser/loader/... content/browser/loader/resource_dispatcher_host_impl.cc:546: DCHECK_CURRENTLY_ON(BrowserThread::IO); On 2016/01/21 16:33:34, mmenke wrote: > May want to add a DCHECK to RemoveResourceContext as well, just for > documentation purposes (And out of paranoia) The reason I didn't is because of the comment about tests destroying the ResourceContext on the UI thread.
On 2016/01/21 19:41:52, Anand Mistry wrote: > https://codereview.chromium.org/1600263002/diff/40001/content/browser/loader/... > File content/browser/loader/resource_dispatcher_host_impl.cc (right): > > https://codereview.chromium.org/1600263002/diff/40001/content/browser/loader/... > content/browser/loader/resource_dispatcher_host_impl.cc:546: > DCHECK_CURRENTLY_ON(BrowserThread::IO); > On 2016/01/21 16:33:34, mmenke wrote: > > May want to add a DCHECK to RemoveResourceContext as well, just for > > documentation purposes (And out of paranoia) > > The reason I didn't is because of the comment about tests destroying the > ResourceContext on the UI thread. Ah, good point. My LGTM still stands without it.
On 2016/01/21 19:45:14, mmenke wrote: > On 2016/01/21 19:41:52, Anand Mistry wrote: > > > https://codereview.chromium.org/1600263002/diff/40001/content/browser/loader/... > > File content/browser/loader/resource_dispatcher_host_impl.cc (right): > > > > > https://codereview.chromium.org/1600263002/diff/40001/content/browser/loader/... > > content/browser/loader/resource_dispatcher_host_impl.cc:546: > > DCHECK_CURRENTLY_ON(BrowserThread::IO); > > On 2016/01/21 16:33:34, mmenke wrote: > > > May want to add a DCHECK to RemoveResourceContext as well, just for > > > documentation purposes (And out of paranoia) > > > > The reason I didn't is because of the comment about tests destroying the > > ResourceContext on the UI thread. > > Ah, good point. My LGTM still stands without it. Hrm... That does mean we can add contexts before removing them in tests, but I don't think that actually breaks anything.
The CQ bit was checked by amistry@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1600263002/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1600263002/40001
On 2016/01/21 19:46:40, mmenke wrote: > On 2016/01/21 19:45:14, mmenke wrote: > > On 2016/01/21 19:41:52, Anand Mistry wrote: > > > > > > https://codereview.chromium.org/1600263002/diff/40001/content/browser/loader/... > > > File content/browser/loader/resource_dispatcher_host_impl.cc (right): > > > > > > > > > https://codereview.chromium.org/1600263002/diff/40001/content/browser/loader/... > > > content/browser/loader/resource_dispatcher_host_impl.cc:546: > > > DCHECK_CURRENTLY_ON(BrowserThread::IO); > > > On 2016/01/21 16:33:34, mmenke wrote: > > > > May want to add a DCHECK to RemoveResourceContext as well, just for > > > > documentation purposes (And out of paranoia) > > > > > > The reason I didn't is because of the comment about tests destroying the > > > ResourceContext on the UI thread. > > > > Ah, good point. My LGTM still stands without it. > > Hrm... That does mean we can add contexts before removing them in tests, but I > don't think that actually breaks anything. It's a possibility if nothing depends on the ResourceContext. Dry run started, lets see what breaks.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
amistry@chromium.org changed reviewers: + kinuko@chromium.org
kinuko@chromium.org: For content OWNERS approval.
lgtm
The CQ bit was checked by amistry@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from kinuko@chromium.org, mmenke@chromium.org Link to the patchset: https://codereview.chromium.org/1600263002/#ps60001 (title: "Rebase")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1600263002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1600263002/60001
Message was sent while issue was closed.
Description was changed from ========== Post a task to the IO thread to add a ResourceContext in ResourceDispatcherHostImpl. ResourceDispatcherHostImpl::AddResourceContext() is called on the UI thread, but all other users of |active_resource_contexts_| access it on the IO thread. ========== to ========== Post a task to the IO thread to add a ResourceContext in ResourceDispatcherHostImpl. ResourceDispatcherHostImpl::AddResourceContext() is called on the UI thread, but all other users of |active_resource_contexts_| access it on the IO thread. ==========
Message was sent while issue was closed.
Committed patchset #4 (id:60001)
Message was sent while issue was closed.
Description was changed from ========== Post a task to the IO thread to add a ResourceContext in ResourceDispatcherHostImpl. ResourceDispatcherHostImpl::AddResourceContext() is called on the UI thread, but all other users of |active_resource_contexts_| access it on the IO thread. ========== to ========== Post a task to the IO thread to add a ResourceContext in ResourceDispatcherHostImpl. ResourceDispatcherHostImpl::AddResourceContext() is called on the UI thread, but all other users of |active_resource_contexts_| access it on the IO thread. Committed: https://crrev.com/3f29b4056e85ed6259b679e9858134422caaf72f Cr-Commit-Position: refs/heads/master@{#371687} ==========
Message was sent while issue was closed.
Patchset 4 (id:??) landed as https://crrev.com/3f29b4056e85ed6259b679e9858134422caaf72f Cr-Commit-Position: refs/heads/master@{#371687} |