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

Issue 1228373006: Reliably cancel in-progress CryptoResult(Impl) upon shutdown. (Closed)

Created:
5 years, 5 months ago by sof
Modified:
5 years, 4 months ago
CC:
blink-reviews
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

Reliably cancel in-progress CryptoResult(Impl) upon shutdown. Move CryptoResult to the Oilpan heap and in order to support such Oilpan-hosted CryptoResults mainly, also separate out the signalling of crypto operation cancellation. CryptoResults are wrapped up (WebCryptoResult) and passed to the embedder's webcrypto layer upon initiating a crypto operation. Should the Blink thread that initiated that operation be shut down (before that crypto operation completes, possibly), it will go through its shutdown steps, including notifying CryptoResults that it is stopping. At which point the implementation has to effectively cancel the ongoing crypto operation. The Oilpan heaps belonging to the thread shutting down cannot be reliably used to communicate cancellation status, as they're about to be detached and destructed also. Hence, we keep a separate off-heap cancellation object that can live beyond the Blink thread that initiated it. And can be used by the webcrypto layer to safely query for cancellation status after the Blink thread has been shut down entirely. As webcrypto operations are handled on separate threads, the cancellation object references can be safely accessed from any thread, including handling their eventual destruction. The same goes for the Oilpan-hosted CryptoResult -- external references (by way of WebPrivatePtr<>) can be held and destructed from any thread. R=haraken,eroman,tkent BUG=440450 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=199878

Patch Set 1 #

Patch Set 2 : non-oilpan compile fix #

Total comments: 3

Patch Set 3 : attempt to address shutdown reliability #

Patch Set 4 : improve comment wording #

Patch Set 5 : have WebCryptoResult handle (cross-thread) cancellation #

Patch Set 6 : have WebCryptoResult::commit*() be gated on cancellation status #

Total comments: 1

Patch Set 7 : Expand protocol for (un)registering WebCryptoResults #

Patch Set 8 : simplify; we are already relying a same/origin thread assumption #

Patch Set 9 : Do not expose Persistent<> to WebCryptoResults #

Patch Set 10 : rebased upto r199421 and use it for (again) heap-based CryptoResults #

Total comments: 1

Patch Set 11 : Revert sync cancellation parts #

Patch Set 12 : Separate out cancellation handling (+rebase) #

Total comments: 14

Patch Set 13 : initialize stopped crypto result as cancelled #

Unified diffs Side-by-side diffs Delta from patch set Stats (+169 lines, -88 lines) Patch
M Source/modules/crypto/CryptoResultImpl.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +42 lines, -12 lines 0 comments Download
M Source/modules/crypto/CryptoResultImpl.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 5 chunks +92 lines, -57 lines 0 comments Download
M Source/modules/crypto/SubtleCrypto.cpp View 9 1 chunk +1 line, -1 line 0 comments Download
M Source/platform/CryptoResult.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +12 lines, -7 lines 0 comments Download
M Source/platform/exported/WebCryptoResult.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +18 lines, -9 lines 0 comments Download
M public/platform/WebCrypto.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +4 lines, -2 lines 0 comments Download

Messages

Total messages: 43 (6 generated)
sof
please take a look. The handling of CryptResultImpl with ENABLE(OILPAN) worked out by accident so ...
5 years, 5 months ago (2015-07-14 13:23:40 UTC) #2
sof
Not entirely ready, Oilpan bot ran into a flaky crash on crypto/subtle/aes-export-key.html Not able to ...
5 years, 5 months ago (2015-07-14 21:06:57 UTC) #3
sof
On 2015/07/14 21:06:57, sof wrote: > Not entirely ready, Oilpan bot ran into a flaky ...
5 years, 5 months ago (2015-07-15 05:25:28 UTC) #4
haraken
Thanks for digging! LGTM once the worker shutdown issue is resolved. https://codereview.chromium.org/1228373006/diff/20001/Source/modules/crypto/CryptoResultImpl.cpp File Source/modules/crypto/CryptoResultImpl.cpp (right): ...
5 years, 5 months ago (2015-07-15 07:55:05 UTC) #6
sof
On 2015/07/15 07:55:05, haraken wrote: > Thanks for digging! LGTM once the worker shutdown issue ...
5 years, 5 months ago (2015-07-15 07:58:05 UTC) #7
sof
Think I have addressed the issue now. In a reasonably clean fashion (but the lifetime ...
5 years, 5 months ago (2015-07-15 12:47:49 UTC) #9
eroman
not lgtm https://codereview.chromium.org/1228373006/diff/100001/Source/modules/crypto/CryptoResultImpl.h File Source/modules/crypto/CryptoResultImpl.h (right): https://codereview.chromium.org/1228373006/diff/100001/Source/modules/crypto/CryptoResultImpl.h#newcode101 Source/modules/crypto/CryptoResultImpl.h:101: WebCryptoResult* m_resultOwner; This doesn't make sense. WebCryptoResult ...
5 years, 5 months ago (2015-07-15 21:34:06 UTC) #10
sof
On 2015/07/15 21:34:06, eroman wrote: > not lgtm > > https://codereview.chromium.org/1228373006/diff/100001/Source/modules/crypto/CryptoResultImpl.h > File Source/modules/crypto/CryptoResultImpl.h (right): ...
5 years, 5 months ago (2015-07-16 05:12:15 UTC) #11
sof
Elaborated the (un)registration of WebCryptoResults from their underlying CryptoResultImpl, along with verifying that when an ...
5 years, 5 months ago (2015-07-21 21:40:22 UTC) #12
sof
On 2015/07/21 21:40:22, sof wrote: > Elaborated the (un)registration of WebCryptoResults from their underlying > ...
5 years, 5 months ago (2015-07-22 13:11:39 UTC) #13
haraken
On 2015/07/22 13:11:39, sof wrote: > On 2015/07/21 21:40:22, sof wrote: > > Elaborated the ...
5 years, 5 months ago (2015-07-22 15:16:39 UTC) #14
sof
On 2015/07/22 15:16:39, haraken wrote: > On 2015/07/22 13:11:39, sof wrote: > > On 2015/07/21 ...
5 years, 5 months ago (2015-07-22 15:26:48 UTC) #15
sof
On 2015/07/22 15:26:48, sof wrote: > On 2015/07/22 15:16:39, haraken wrote: > > On 2015/07/22 ...
5 years, 5 months ago (2015-07-22 15:53:42 UTC) #16
sof
On 2015/07/22 15:53:42, sof wrote: > On 2015/07/22 15:26:48, sof wrote: > > On 2015/07/22 ...
5 years, 5 months ago (2015-07-22 21:19:23 UTC) #17
sof
On 2015/07/22 21:19:23, sof wrote: > ... > > ps#4 of https://codereview.chromium.org/1249913002/ explores the alternative ...
5 years, 5 months ago (2015-07-24 08:26:44 UTC) #18
eroman
Can you give some more context on what this change is trying to accomplish? I ...
5 years, 5 months ago (2015-07-25 01:44:38 UTC) #19
sof
On 2015/07/25 01:44:38, eroman wrote: > Can you give some more context on what this ...
5 years, 5 months ago (2015-07-26 18:31:56 UTC) #20
eroman
On Sun, Jul 26, 2015 at 11:31 AM, <sigbjornf@opera.com> wrote: > On 2015/07/25 01:44:38, eroman ...
5 years, 4 months ago (2015-07-27 19:13:25 UTC) #21
sof1
Den 7/27/2015 21:13, Eric Roman skreiv: > > > On Sun, Jul 26, 2015 at ...
5 years, 4 months ago (2015-07-27 20:35:45 UTC) #22
eroman
On Mon, Jul 27, 2015 at 1:35 PM, Sigbjorn Finne <sof@opera.com> wrote: > Den 7/27/2015 ...
5 years, 4 months ago (2015-07-27 21:13:36 UTC) #23
sof1
Den 7/27/2015 23:13, Eric Roman skreiv: > > > On Mon, Jul 27, 2015 at ...
5 years, 4 months ago (2015-07-28 07:37:44 UTC) #24
sof1
Den 7/27/2015 21:13, Eric Roman skreiv: > > ... > > What prevents the execution ...
5 years, 4 months ago (2015-07-28 12:58:58 UTC) #25
sof
Hmm, crypto/subtle/aes-export-key.html is flakily failing on the Oilpan debug bot with the last, cut-down patchset.
5 years, 4 months ago (2015-07-29 12:13:50 UTC) #26
sof
On 2015/07/29 12:13:50, sof wrote: > Hmm, crypto/subtle/aes-export-key.html is flakily failing on the Oilpan debug ...
5 years, 4 months ago (2015-07-29 13:30:15 UTC) #27
sof
On 2015/07/29 13:30:15, sof wrote: > On 2015/07/29 12:13:50, sof wrote: > > Hmm, crypto/subtle/aes-export-key.html ...
5 years, 4 months ago (2015-07-30 11:10:42 UTC) #28
sof
On 2015/07/30 11:10:42, sof wrote: > On 2015/07/29 13:30:15, sof wrote: > > On 2015/07/29 ...
5 years, 4 months ago (2015-07-31 08:11:17 UTC) #29
eroman
LGTM! Thanks for working through my concerns and handling this issue. I find this modified ...
5 years, 4 months ago (2015-07-31 23:40:30 UTC) #30
eroman
https://codereview.chromium.org/1228373006/diff/220001/Source/modules/crypto/CryptoResultImpl.cpp File Source/modules/crypto/CryptoResultImpl.cpp (right): https://codereview.chromium.org/1228373006/diff/220001/Source/modules/crypto/CryptoResultImpl.cpp#newcode139 Source/modules/crypto/CryptoResultImpl.cpp:139: return; IMPORTANT: This return doesn't seem right. In the ...
5 years, 4 months ago (2015-08-01 00:13:14 UTC) #31
sof
Thanks much for the review, we arrived at something quite reasonable in the end. mkwst, ...
5 years, 4 months ago (2015-08-01 06:44:31 UTC) #33
haraken
(I'm not following the details but want to say thank you :-)
5 years, 4 months ago (2015-08-01 15:25:54 UTC) #34
tkent
public lgtm
5 years, 4 months ago (2015-08-02 23:39:14 UTC) #35
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1228373006/240001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1228373006/240001
5 years, 4 months ago (2015-08-03 05:09:34 UTC) #38
commit-bot: I haz the power
Committed patchset #13 (id:240001) as https://src.chromium.org/viewvc/blink?view=rev&revision=199878
5 years, 4 months ago (2015-08-03 06:44:36 UTC) #39
eroman
https://codereview.chromium.org/1228373006/diff/220001/Source/modules/crypto/CryptoResultImpl.cpp File Source/modules/crypto/CryptoResultImpl.cpp (right): https://codereview.chromium.org/1228373006/diff/220001/Source/modules/crypto/CryptoResultImpl.cpp#newcode139 Source/modules/crypto/CryptoResultImpl.cpp:139: return; On 2015/08/01 06:44:30, sof wrote: > On 2015/08/01 ...
5 years, 4 months ago (2015-08-03 19:00:29 UTC) #40
sof
On 2015/08/03 19:00:29, eroman wrote: > https://codereview.chromium.org/1228373006/diff/220001/Source/modules/crypto/CryptoResultImpl.cpp > File Source/modules/crypto/CryptoResultImpl.cpp (right): > > https://codereview.chromium.org/1228373006/diff/220001/Source/modules/crypto/CryptoResultImpl.cpp#newcode139 > ...
5 years, 4 months ago (2015-08-03 19:03:07 UTC) #41
eroman
https://codereview.chromium.org/1228373006/diff/220001/Source/modules/crypto/CryptoResultImpl.cpp File Source/modules/crypto/CryptoResultImpl.cpp (right): https://codereview.chromium.org/1228373006/diff/220001/Source/modules/crypto/CryptoResultImpl.cpp#newcode139 Source/modules/crypto/CryptoResultImpl.cpp:139: return; On 2015/08/03 19:00:29, eroman wrote: > On 2015/08/01 ...
5 years, 4 months ago (2015-08-03 19:45:35 UTC) #42
sof
5 years, 4 months ago (2015-08-03 19:59:56 UTC) #43
Message was sent while issue was closed.
On 2015/08/03 19:45:35, eroman wrote:
>
https://codereview.chromium.org/1228373006/diff/220001/Source/modules/crypto/...
> File Source/modules/crypto/CryptoResultImpl.cpp (right):
> 
....
> > 
> > The WebCryptoResult ctor will merely ASSERT().
> > 
> > It is important to handle this, otherwise we are going to crash later.
> > 
> > If we can reach this codepath, then we will be able to reach the
> completeWith*()
> > codepath as well, which is then going to crash....
> > 
> > The only case this doesn't matter is if you can prove that this branch is
> never
> > entered.
> 
> Ah, I didn't notice that you addressed this in the following patchset, please
> disregard then :)
> 

ok, thanks for confirming - no shortage of patchsets to sift through here :)

Powered by Google App Engine
This is Rietveld 408576698