Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Issue 2528233003: Defend against RPHI::ForceReleaseWorkerRefCount called twice.

Created:
4 years ago by falken
Modified:
4 years ago
Reviewers:
horo
CC:
chromium-reviews, jam, nasko+codewatch_chromium.org, darin-cc_chromium.org, creis+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Defend against RPHI::ForceReleaseWorkerRefCount called twice. If a BrowserContext is destroyed and a new one created with the same address, RPHI::ForceReleaseWorkerRefCount can be called twice since pointer comparison is used to determine which context owns a RPHI. See bug for details. This patch early returns if ForceReleaseWorkerRefCount was already called. Another approach could be to clear browser_context_ in ForceReleaseWorkerRefCount but that could be risky since Cleanup() may dereference browser_context_. BUG=661843

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+6 lines, -1 line) Patch
M content/browser/renderer_host/render_process_host_impl.cc View 1 chunk +6 lines, -1 line 4 comments Download

Messages

Total messages: 10 (5 generated)
falken
horo@ can you review?
4 years ago (2016-11-28 07:11:03 UTC) #2
horo
https://codereview.chromium.org/2528233003/diff/1/content/browser/renderer_host/render_process_host_impl.cc File content/browser/renderer_host/render_process_host_impl.cc (right): https://codereview.chromium.org/2528233003/diff/1/content/browser/renderer_host/render_process_host_impl.cc#newcode1405 content/browser/renderer_host/render_process_host_impl.cc:1405: // https://crbug.com/661843. I think we should introduce RenderProcessHostImpl::OnContextWillBeDestroyed() which ...
4 years ago (2016-11-28 07:26:51 UTC) #5
falken
https://codereview.chromium.org/2528233003/diff/1/content/browser/renderer_host/render_process_host_impl.cc File content/browser/renderer_host/render_process_host_impl.cc (right): https://codereview.chromium.org/2528233003/diff/1/content/browser/renderer_host/render_process_host_impl.cc#newcode1405 content/browser/renderer_host/render_process_host_impl.cc:1405: // https://crbug.com/661843. On 2016/11/28 07:26:51, horo wrote: > I ...
4 years ago (2016-11-28 07:34:21 UTC) #6
horo
https://codereview.chromium.org/2528233003/diff/1/content/browser/renderer_host/render_process_host_impl.cc File content/browser/renderer_host/render_process_host_impl.cc (right): https://codereview.chromium.org/2528233003/diff/1/content/browser/renderer_host/render_process_host_impl.cc#newcode1405 content/browser/renderer_host/render_process_host_impl.cc:1405: // https://crbug.com/661843. On 2016/11/28 07:34:21, falken wrote: > On ...
4 years ago (2016-11-28 08:54:41 UTC) #9
falken
4 years ago (2016-11-29 04:19:36 UTC) #10
https://codereview.chromium.org/2528233003/diff/1/content/browser/renderer_ho...
File content/browser/renderer_host/render_process_host_impl.cc (right):

https://codereview.chromium.org/2528233003/diff/1/content/browser/renderer_ho...
content/browser/renderer_host/render_process_host_impl.cc:1405: //
https://crbug.com/661843.
On 2016/11/28 08:54:40, horo wrote:
> On 2016/11/28 07:34:21, falken wrote:
> > On 2016/11/28 07:26:51, horo wrote:
> > > I think we should introduce
> RenderProcessHostImpl::OnContextWillBeDestroyed()
> > > which sets browser_context_ to null and calls
ForceReleaseWorkerRefCounts().
> > 
> > Hm, I considered this (see CL description) but Cleanup() uses
browser_context_
> > and also sometimes doesn't to run synchronously ("delayed_cleanup_needed").
So
> > I'm not sure it's safe to clear browser_context_ even after calling
Cleanup().
> 
> After BrowserContext::NotifyWillBeDestroyed() is called, we should not refer
the
> browser_context.
> So we should set browser_context_ to null in the end of
> RenderProcessHostImpl::OnContextWillBeDestroyed().
>  RenderProcessHostImpl::OnContextWillBeDestroyed() {
>    ForceReleaseWorkerRefCounts();
>    browser_context_ = nullptr;
>  }
> 
> The browser_context may be alive even after
> BrowserContext::NotifyWillBeDestroyed().
> But this is a bug that MUST BE FIXED.
>
https://chromium.googlesource.com/chromium/src/+/b15e190/chrome/browser/profi...

Hm yea I'm no longer sure of either solution. //content assumes that
BrowserContext outlives its RPHI. So any tricks to prevent a stale
browser_context_ pointer are just working around the fact that somehow this
expectation is violated, and a DCHECK like ProfileDestroyer above would be
better to make the violation explicitly known.

Powered by Google App Engine
This is Rietveld 408576698