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

Issue 1414683003: Fix gpu command buffer use after free by GrContext (Closed)

Created:
5 years, 1 month ago by Justin Novosad
Modified:
5 years, 1 month ago
CC:
chromium-reviews, krit, pdr+graphicswatchlist_chromium.org, drott+blinkwatch_chromium.org, vmpstr+blinkwatch_chromium.org, dshwang, jbroman, danakj, blink-reviews-platform-graphics_chromium.org, Rik, f(malita), blink-reviews, piman+watch_chromium.org, Stephen Chennney, rwlbuis
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix gpu command buffer use after free by GrContext ContextProviderCommandBuffer owns a WebGraphicsContext3DCommandBufferImpl and a GrContextForWebGraphicsContext3D via scoped_ptr. The problem was that the GrContext object held by GrContextForWebGraphicsContext3D depended on interface pointers that reference an interface that is owned by WebGraphicsContext3DCommandBufferImpl, so whenever the GrContext outlived the ContextProviderCommandBuffer, we ended up in a state where the interface function pointers are deallocated, but still referenced. Then, attempts to use the GrContext would result in using deallocated function pointers. Because the GrContext is a ref counted object, it can easily outlive the ContextProviderCommandBuffer. This led to a dangerous situation where we had to be careful about object destruction order. This CL fixes the problem for good by wrapping the ownership of the WebGraphicsContext3DCommandBufferImpl into a subclass of GrGLInterface, which is a ref counted object that can be owned jointly by the GrContext and the ContextProviderCommandBuffer, thus guaranteeing that the command buffer interface will remain valid for the lifetimes of the GrContext and of the ContextProviderCommandBuffer. BUG=551143 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Committed: https://crrev.com/d87aa1f1aee6ab0181eadaae827a5768981c1ccc Cr-Commit-Position: refs/heads/master@{#359493}

Patch Set 1 #

Patch Set 2 : WIP #

Patch Set 3 : added test #

Patch Set 4 : debug fix + style #

Patch Set 5 : blind android fix #

Total comments: 1

Patch Set 6 : thread check + various tweaks #

Patch Set 7 : android build fix + adding BindToCurrentThread on gr_interface_ #

Total comments: 1

Patch Set 8 : applied boliu feedback #

Patch Set 9 : android build fix #

Patch Set 10 : fix android webview build + browser test #

Total comments: 5

Patch Set 11 : tweaks #

Patch Set 12 : blimp build fix #

Patch Set 13 : try enabling test on all platforms #

Patch Set 14 : test fixup #

Unified diffs Side-by-side diffs Delta from patch set Stats (+184 lines, -82 lines) Patch
M android_webview/browser/aw_render_thread_context_provider.cc View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -2 lines 0 comments Download
M blimp/client/compositor/blimp_context_provider.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +2 lines, -2 lines 0 comments Download
M cc/test/test_in_process_context_provider.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M content/browser/android/in_process/context_provider_in_process.h View 1 2 3 4 4 chunks +5 lines, -2 lines 0 comments Download
M content/browser/android/in_process/context_provider_in_process.cc View 1 2 3 4 5 6 7 8 8 chunks +30 lines, -18 lines 0 comments Download
M content/browser/gpu/gpu_ipc_browsertests.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +47 lines, -0 lines 0 comments Download
M content/common/gpu/client/context_provider_command_buffer.h View 1 3 chunks +5 lines, -1 line 0 comments Download
M content/common/gpu/client/context_provider_command_buffer.cc View 1 2 3 4 5 6 7 8 9 10 7 chunks +32 lines, -23 lines 0 comments Download
M content/common/gpu/client/grcontext_for_webgraphicscontext3d.h View 1 2 3 4 5 6 2 chunks +26 lines, -1 line 0 comments Download
M content/common/gpu/client/grcontext_for_webgraphicscontext3d.cc View 1 2 3 4 5 6 3 chunks +28 lines, -14 lines 0 comments Download
M gpu/blink/webgraphicscontext3d_impl.h View 1 1 chunk +0 lines, -2 lines 0 comments Download
M gpu/blink/webgraphicscontext3d_impl.cc View 1 2 chunks +0 lines, -5 lines 0 comments Download
M gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h View 1 1 chunk +2 lines, -2 lines 0 comments Download
M gpu/skia_bindings/gl_bindings_skia_cmd_buffer.cc View 1 2 chunks +1 line, -4 lines 0 comments Download
M third_party/WebKit/public/platform/WebGraphicsContext3D.h View 1 1 chunk +0 lines, -2 lines 0 comments Download
M ui/compositor/test/in_process_context_provider.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 24 (8 generated)
Justin Novosad
Reviewers: rbyers for third_party/WebKit/public/OWNERS kbr for content/common/gpu/OWNERS and content/browser/gpu/OWNERS piman for gpu/OWNERS danakj for cc/OWNERS ...
5 years, 1 month ago (2015-11-09 15:39:05 UTC) #5
Rick Byers
WebKit/public RS LGTM
5 years, 1 month ago (2015-11-09 16:01:39 UTC) #6
piman
My main concern is that now the context may be kept alive longer, and possibly ...
5 years, 1 month ago (2015-11-09 19:29:25 UTC) #7
Justin Novosad
On 2015/11/09 19:29:25, piman (slow to review) wrote: > My main concern is that now ...
5 years, 1 month ago (2015-11-09 19:40:42 UTC) #8
Justin Novosad
+ boliu for content/browser/android/in_process/OWNERS
5 years, 1 month ago (2015-11-09 21:01:25 UTC) #10
piman
lgtm
5 years, 1 month ago (2015-11-09 23:24:02 UTC) #11
boliu
in_process lgtm https://codereview.chromium.org/1414683003/diff/120001/content/browser/android/in_process/context_provider_in_process.cc File content/browser/android/in_process/context_provider_in_process.cc (right): https://codereview.chromium.org/1414683003/diff/120001/content/browser/android/in_process/context_provider_in_process.cc#newcode81 content/browser/android/in_process/context_provider_in_process.cc:81: gr_interface_->WebContext3D()); nit: This can just call WebContext3D ...
5 years, 1 month ago (2015-11-10 00:51:30 UTC) #12
Ken Russell (switch to Gerrit)
lgtm if this has been tested, but I didn't check all of the code that ...
5 years, 1 month ago (2015-11-11 19:14:49 UTC) #13
Ken Russell (switch to Gerrit)
https://codereview.chromium.org/1414683003/diff/170001/content/browser/gpu/gpu_ipc_browsertests.cc File content/browser/gpu/gpu_ipc_browsertests.cc (right): https://codereview.chromium.org/1414683003/diff/170001/content/browser/gpu/gpu_ipc_browsertests.cc#newcode209 content/browser/gpu/gpu_ipc_browsertests.cc:209: MAYBE_GrContextKeepsGpuChannelAlive) { It looks like this new test's failing ...
5 years, 1 month ago (2015-11-11 19:16:52 UTC) #14
Justin Novosad
https://codereview.chromium.org/1414683003/diff/170001/content/common/gpu/client/context_provider_command_buffer.cc File content/common/gpu/client/context_provider_command_buffer.cc (right): https://codereview.chromium.org/1414683003/diff/170001/content/common/gpu/client/context_provider_command_buffer.cc#newcode85 content/common/gpu/client/context_provider_command_buffer.cc:85: ContextProviderCommandBuffer::WebContext3DNoChecks() { On 2015/11/11 19:14:49, Ken Russell wrote: > ...
5 years, 1 month ago (2015-11-12 19:18:46 UTC) #15
Justin Novosad
+dtrainor for blimp/OWNERS
5 years, 1 month ago (2015-11-12 21:36:38 UTC) #17
David Trainor- moved to gerrit
blimp lgtm
5 years, 1 month ago (2015-11-12 22:06:03 UTC) #18
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1414683003/250001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1414683003/250001
5 years, 1 month ago (2015-11-13 03:42:16 UTC) #21
commit-bot: I haz the power
Committed patchset #14 (id:250001)
5 years, 1 month ago (2015-11-13 04:47:23 UTC) #22
commit-bot: I haz the power
Patchset 14 (id:??) landed as https://crrev.com/d87aa1f1aee6ab0181eadaae827a5768981c1ccc Cr-Commit-Position: refs/heads/master@{#359493}
5 years, 1 month ago (2015-11-13 04:48:49 UTC) #23
cbiesinger
5 years, 1 month ago (2015-11-13 18:57:40 UTC) #24
Message was sent while issue was closed.
A revert of this CL (patchset #14 id:250001) has been created in
https://codereview.chromium.org/1444683002/ by cbiesinger@chromium.org.

The reason for reverting is: Reverting because this breaks several layout tests:
STDERR:
[3888:1580:1113/081604:621866:FATAL:context_provider_command_buffer.cc(79)]
Check failed: context_thread_checker_.CalledOnValidThread(). 
STDERR: Backtrace:
STDERR: 	base::debug::StackTrace::StackTrace [0x00D8DC31+33]
STDERR: 	logging::LogMessage::~LogMessage [0x00DE69DB+75]
STDERR: 	content::ContextProviderCommandBuffer::WebContext3D [0x11BB5DA7+887]
STDERR: 	content::ContextProviderCommandBuffer::ContextGL [0x11BB481B+267]
STDERR: 	content::RenderThreadImpl::SharedWorkerContextProvider [0x1202B2A0+400]
STDERR: 	content::RenderWidget::CreateOutputSurface [0x12089254+452]
STDERR: 	content::RenderWidgetCompositor::RequestNewOutputSurface
[0x11E7767F+127]


https://storage.googleapis.com/chromium-layout-test-archives/WebKit_Win7__dbg...

https://build.chromium.org/p/chromium.webkit/builders/WebKit%20Win7%20%28dbg%....

Powered by Google App Engine
This is Rietveld 408576698