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

Issue 1912223002: Make new WebUSB implementation more resilient to garbage collection. (Closed)

Created:
4 years, 8 months ago by Reilly Grant (use Gerrit)
Modified:
4 years, 8 months ago
CC:
blink-reviews, chromium-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Make new WebUSB implementation more resilient to garbage collection. This patch fixes a couple logic errors on USBDevice cleanup: assuming the contextDestroyed() was already called and not clearing the request list on connection failure. We then attempt to fix the failures reported in issue 605487 by using WeakPersistenThisPointer when registering the connection error callbacks. BUG=605487 Committed: https://crrev.com/d1174ce5ac7e0b7c3300e5607e7869327ec0669f Cr-Commit-Position: refs/heads/master@{#389610}

Patch Set 1 #

Total comments: 2

Patch Set 2 : Rebased and reverted TestExpectations changes. #

Patch Set 3 : Rebased again. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+68 lines, -42 lines) Patch
M third_party/WebKit/LayoutTests/TestExpectations View 1 2 1 chunk +0 lines, -9 lines 0 comments Download
M third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js View 1 2 1 chunk +8 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/usb/usbDevice.html View 2 chunks +12 lines, -1 line 0 comments Download
M third_party/WebKit/Source/modules/webusb/USB.h View 1 chunk +3 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/webusb/USB.cpp View 1 4 chunks +28 lines, -21 lines 0 comments Download
M third_party/WebKit/Source/modules/webusb/USBDevice.h View 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/modules/webusb/USBDevice.cpp View 1 3 chunks +15 lines, -11 lines 0 comments Download

Messages

Total messages: 34 (11 generated)
Reilly Grant (use Gerrit)
Ken, please take a look.
4 years, 8 months ago (2016-04-22 18:02:38 UTC) #2
Ken Rockot(use gerrit already)
Hmm. After examining the bindings more closely, I'm pretty well convinced that all these weak ...
4 years, 8 months ago (2016-04-22 19:52:02 UTC) #3
Reilly Grant (use Gerrit)
On 2016/04/22 at 19:52:02, rockot wrote: > Hmm. After examining the bindings more closely, I'm ...
4 years, 8 months ago (2016-04-22 19:59:46 UTC) #4
Reilly Grant (use Gerrit)
Line 106 in USBDevice.cpp is: m_device.reset(); So I'm guessing that |this| is an invalid pointer ...
4 years, 8 months ago (2016-04-22 20:00:53 UTC) #5
Reilly Grant (use Gerrit)
This patch does appear to fix the crashing tests but the stack trace appears to ...
4 years, 8 months ago (2016-04-22 20:26:33 UTC) #6
esprehn
Hmm, I feel like the amount of manual oilpan stuff going on in modules and ...
4 years, 8 months ago (2016-04-23 00:54:02 UTC) #8
Reilly Grant (use Gerrit)
Adding haraken@ for help understanding Oilpan semantics.
4 years, 8 months ago (2016-04-24 23:11:15 UTC) #10
haraken
The WeakPersistentThisPointer is nasty but it will be gone in hiroshige's refactoring. So I'm okay ...
4 years, 8 months ago (2016-04-25 08:47:05 UTC) #12
Reilly Grant (use Gerrit)
On 2016/04/25 at 08:47:05, haraken wrote: > The WeakPersistentThisPointer is nasty but it will be ...
4 years, 8 months ago (2016-04-25 15:09:00 UTC) #13
haraken
On 2016/04/25 15:09:00, Reilly Grant wrote: > On 2016/04/25 at 08:47:05, haraken wrote: > > ...
4 years, 8 months ago (2016-04-25 15:30:48 UTC) #14
Ken Rockot(use gerrit already)
OK - LGTM but haraken can you please help us understand how this is possible? ...
4 years, 8 months ago (2016-04-25 15:39:17 UTC) #15
Reilly Grant (use Gerrit)
On 2016/04/25 at 15:39:17, rockot wrote: > Reilly I see USBDevice is GarbageCollectedFinalized, but USB ...
4 years, 8 months ago (2016-04-25 15:44:08 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1912223002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1912223002/20001
4 years, 8 months ago (2016-04-25 18:20:51 UTC) #19
haraken
On 2016/04/25 15:39:17, Ken Rockot wrote: > OK - LGTM but haraken can you please ...
4 years, 8 months ago (2016-04-25 19:15:45 UTC) #20
Reilly Grant (use Gerrit)
On 2016/04/25 at 19:15:45, haraken wrote: > On 2016/04/25 15:39:17, Ken Rockot wrote: > > ...
4 years, 8 months ago (2016-04-25 19:19:41 UTC) #21
commit-bot: I haz the power
Failed to commit the patch.
4 years, 8 months ago (2016-04-25 20:09:39 UTC) #23
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1912223002/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1912223002/40001
4 years, 8 months ago (2016-04-25 20:31:44 UTC) #27
esprehn
I think the fix here is to use WTF::bind, we shouldn't be using C++ lambda ...
4 years, 8 months ago (2016-04-25 20:47:25 UTC) #28
Reilly Grant (use Gerrit)
On 2016/04/25 at 20:47:25, esprehn wrote: > I think the fix here is to use ...
4 years, 8 months ago (2016-04-25 21:03:09 UTC) #29
commit-bot: I haz the power
Committed patchset #3 (id:40001)
4 years, 8 months ago (2016-04-25 23:33:03 UTC) #30
commit-bot: I haz the power
Patchset 3 (id:??) landed as https://crrev.com/d1174ce5ac7e0b7c3300e5607e7869327ec0669f Cr-Commit-Position: refs/heads/master@{#389610}
4 years, 8 months ago (2016-04-25 23:34:35 UTC) #32
sof
On 2016/04/25 21:03:09, Reilly Grant wrote: > On 2016/04/25 at 20:47:25, esprehn wrote: > > ...
4 years, 8 months ago (2016-04-26 05:28:09 UTC) #33
haraken
4 years, 8 months ago (2016-04-26 07:08:09 UTC) #34
Message was sent while issue was closed.
On 2016/04/26 05:28:09, sof wrote:
> On 2016/04/25 21:03:09, Reilly Grant wrote:
> > On 2016/04/25 at 20:47:25, esprehn wrote:
> > > I think the fix here is to use WTF::bind, we shouldn't be using C++ lambda
> in
> > places where the lifetimes it produces are wrong.
> > 
> > And the reason that the C++ lambda produces an incorrect lifetime is that
> > sweeping is lazy and so the message loop may run in between the object being
> > marked unreachable and it being destroyed. Otherwise the destruction of the
> Mojo
> > InterfacePtrs held as members of USB and USBDevice would make the raw
pointer
> > lifetime correct.
> 
> Which could have been addressed by making the objects be eagerly finalized,
but
> "weakifiying" the callbacks as you did here works just as well, if not better.

C++ lambda functions can cause this kind of issue, so I think we should forbid
C++ lambda functions and instead use WTF::Function + WTF::bind for binding
callback functions.

Powered by Google App Engine
This is Rietveld 408576698