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

Issue 10909068: Fix resource leaks in CDM implementation. (Closed)

Created:
8 years, 3 months ago by Tom Finegan
Modified:
8 years, 3 months ago
CC:
chromium-reviews, feature-media-reviews_chromium.org, darin-cc_chromium.org
Visibility:
Public.

Description

Fix resource leaks in CDM implementation. Two fixes: 1) Add a PassRef constructor to pp::Buffer_Dev to deal with reference counting issues related to passing PP_Resources across the IPC proxy, and use it to avoid adding unnecessary references on PP_Resources. 2) Use the PassRef ScopedPPResource contructor in PluginInstance::Decrypt to avoid added an unnecessary reference on the buffer resource before it's passed to the plugin interface code. BUG=146200 TEST=PPB_Testing_Dev::GetLiveObjectsForInstance shows a stable live object count. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=155145

Patch Set 1 #

Patch Set 2 : Remove includes from my debug runs... #

Total comments: 9

Patch Set 3 : Use ScopedPPResource in PluginInstance::DeliverBlock #

Total comments: 12

Patch Set 4 : Address ddorwin's comments. #

Total comments: 7

Patch Set 5 : Work done per dmichael's comments #

Total comments: 6

Patch Set 6 : I think we have a winner this time... #

Patch Set 7 : Fix leaked ref in CdmWrapper::DeliverBlock #

Total comments: 4

Patch Set 8 : Hopefully all set for CQ #

Patch Set 9 : Same patchset as number 8, hopefully this one is viewable... #

Total comments: 4

Patch Set 10 : Updates per last set of comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+44 lines, -22 lines) Patch
M ppapi/cpp/dev/buffer_dev.h View 1 2 3 4 5 6 7 1 chunk +4 lines, -0 lines 0 comments Download
M ppapi/cpp/dev/buffer_dev.cc View 1 2 3 4 1 chunk +5 lines, -0 lines 0 comments Download
M ppapi/cpp/private/content_decryptor_private.cc View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
M ppapi/proxy/ppp_content_decryptor_private_proxy.cc View 1 2 3 4 5 6 7 3 chunks +23 lines, -8 lines 0 comments Download
M webkit/media/crypto/ppapi/cdm_wrapper.cc View 1 2 3 4 5 6 7 8 9 4 chunks +6 lines, -9 lines 0 comments Download
M webkit/plugins/ppapi/ppapi_plugin_instance.cc View 1 2 3 4 5 6 4 chunks +4 lines, -3 lines 0 comments Download

Messages

Total messages: 19 (0 generated)
Tom Finegan
dmichael, These three small changes stabilize the live object count, and should hopefully be all ...
8 years, 3 months ago (2012-09-04 22:18:03 UTC) #1
Tom Finegan
ddorwin, xhwang, PTAL as well; I'll need a webkit/media owner's LGTM. Thanks!
8 years, 3 months ago (2012-09-04 22:55:41 UTC) #2
ddorwin
LGTM for webkit/media OWNERS. I defer to dmichael for ppapi refcounting issues. http://codereview.chromium.org/10909068/diff/2001/webkit/plugins/ppapi/ppapi_plugin_instance.cc File webkit/plugins/ppapi/ppapi_plugin_instance.cc ...
8 years, 3 months ago (2012-09-05 08:44:44 UTC) #3
xhwang
http://codereview.chromium.org/10909068/diff/2001/webkit/media/crypto/ppapi/cdm_wrapper.cc File webkit/media/crypto/ppapi/cdm_wrapper.cc (right): http://codereview.chromium.org/10909068/diff/2001/webkit/media/crypto/ppapi/cdm_wrapper.cc#newcode237 webkit/media/crypto/ppapi/cdm_wrapper.cc:237: pp::Module::Get()->core()->ReleaseResource(encrypted_buffer.pp_resource()); Is this ReleaseResource called because we are passing ...
8 years, 3 months ago (2012-09-05 09:26:55 UTC) #4
Tom Finegan
Using ScopedPPResource (hopefully) addresses all existing comments. Leak remains fixed in my check out. http://codereview.chromium.org/10909068/diff/2001/webkit/media/crypto/ppapi/cdm_wrapper.cc ...
8 years, 3 months ago (2012-09-05 16:04:40 UTC) #5
ddorwin
LGTM % nits. Go ahead and commit if you get dmichael's approval. http://codereview.chromium.org/10909068/diff/11001/webkit/plugins/ppapi/ppapi_plugin_instance.cc File webkit/plugins/ppapi/ppapi_plugin_instance.cc ...
8 years, 3 months ago (2012-09-05 16:17:51 UTC) #6
Tom Finegan
http://codereview.chromium.org/10909068/diff/11001/webkit/plugins/ppapi/ppapi_plugin_instance.cc File webkit/plugins/ppapi/ppapi_plugin_instance.cc (right): http://codereview.chromium.org/10909068/diff/11001/webkit/plugins/ppapi/ppapi_plugin_instance.cc#newcode23 webkit/plugins/ppapi/ppapi_plugin_instance.cc:23: #include "ppapi/c/dev/ppb_testing_dev.h" On 2012/09/05 16:17:51, ddorwin wrote: > This ...
8 years, 3 months ago (2012-09-05 16:41:56 UTC) #7
dmichael (off chromium)
This reference counting stuff in the proxy is tricky. These comments are based on how ...
8 years, 3 months ago (2012-09-05 17:13:06 UTC) #8
dmichael (off chromium)
http://codereview.chromium.org/10909068/diff/13004/ppapi/proxy/ppp_content_decryptor_private_proxy.cc File ppapi/proxy/ppp_content_decryptor_private_proxy.cc (left): http://codereview.chromium.org/10909068/diff/13004/ppapi/proxy/ppp_content_decryptor_private_proxy.cc#oldcode146 ppapi/proxy/ppp_content_decryptor_private_proxy.cc:146: core->AddRefResource(encrypted_block); Okay, I think I had it wrong before. ...
8 years, 3 months ago (2012-09-05 18:08:37 UTC) #9
Tom Finegan
Possibly one last bit of work to do in PluginInstance::DeliverBlock; hopefully LGTM'able otherwise. http://codereview.chromium.org/10909068/diff/2001/ppapi/proxy/ppp_content_decryptor_private_proxy.cc File ...
8 years, 3 months ago (2012-09-05 19:21:43 UTC) #10
dmichael (off chromium)
http://codereview.chromium.org/10909068/diff/10005/ppapi/cpp/dev/buffer_dev.h File ppapi/cpp/dev/buffer_dev.h (right): http://codereview.chromium.org/10909068/diff/10005/ppapi/cpp/dev/buffer_dev.h#newcode26 ppapi/cpp/dev/buffer_dev.h:26: /// assigned. An additional reference is not taken. How ...
8 years, 3 months ago (2012-09-05 19:46:19 UTC) #11
Tom Finegan
I think this is ready for the CQ. I have to run to the DMV, ...
8 years, 3 months ago (2012-09-05 20:15:26 UTC) #12
dmichael (off chromium)
Sorry, I'm just getting "error: old chunk mismatch" when I try to review. Can you ...
8 years, 3 months ago (2012-09-05 20:55:38 UTC) #13
Tom Finegan
Same patchset reuploaded. I saw the chunk mismatch error, too. Not sure what the deal ...
8 years, 3 months ago (2012-09-06 00:42:54 UTC) #14
dmichael (off chromium)
One last thing, o/w lgtm https://chromiumcodereview.appspot.com/10909068/diff/10016/webkit/media/crypto/ppapi/cdm_wrapper.cc File webkit/media/crypto/ppapi/cdm_wrapper.cc (right): https://chromiumcodereview.appspot.com/10909068/diff/10016/webkit/media/crypto/ppapi/cdm_wrapper.cc#newcode266 webkit/media/crypto/ppapi/cdm_wrapper.cc:266: key_message.message_size).pp_resource()); Don't call pp_resource; ...
8 years, 3 months ago (2012-09-06 02:46:51 UTC) #15
Tom Finegan
Used pp::Buffer_Dev instead of pp::Resource-- would've had to add another Buffer_Dev constructor otherwise. http://codereview.chromium.org/10909068/diff/10016/webkit/media/crypto/ppapi/cdm_wrapper.cc File ...
8 years, 3 months ago (2012-09-06 04:01:02 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/tomfinegan@chromium.org/10909068/14002
8 years, 3 months ago (2012-09-06 04:05:41 UTC) #17
commit-bot: I haz the power
Change committed as 155145
8 years, 3 months ago (2012-09-06 08:31:30 UTC) #18
ddorwin
8 years, 3 months ago (2012-09-06 08:39:01 UTC) #19
Providing context on something I requested. It's fine to address later if that's
what we decide.

http://codereview.chromium.org/10909068/diff/13004/webkit/plugins/ppapi/ppapi...
File webkit/plugins/ppapi/ppapi_plugin_instance.cc (right):

http://codereview.chromium.org/10909068/diff/13004/webkit/plugins/ppapi/ppapi...
webkit/plugins/ppapi/ppapi_plugin_instance.cc:2189: DCHECK(decrypted_block ==
0);
On 2012/09/05 19:21:43, tomf wrote:
> On 2012/09/05 17:13:06, dmichael wrote:
> > Don't we get here via a call from the CDM plugin? If so, we can't trust the
> > inputs, and we shouldn't crash on bad input.
> 
> Done.

I suggested this. My concern was that we might leak buffers on errors. If it's a
DCHECK, then we crash in debug mode if a CDM is misbehaving. CDMs aren't just
random pieces of code, so it seems fine to crash in debug if they have a bug.

Powered by Google App Engine
This is Rietveld 408576698