Bug 227160 - Functions dispatched to WorkQueue are sometimes destroyed in the calling thread due to block refcounting
Summary: Functions dispatched to WorkQueue are sometimes destroyed in the calling thre...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kimmo Kinnunen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-18 01:00 PDT by Kimmo Kinnunen
Modified: 2021-06-22 06:26 PDT (History)
11 users (show)

See Also:


Attachments
Patch (9.48 KB, patch)
2021-06-18 01:30 PDT, Kimmo Kinnunen
no flags Details | Formatted Diff | Diff
Patch for landing (9.50 KB, patch)
2021-06-18 03:43 PDT, Kimmo Kinnunen
no flags Details | Formatted Diff | Diff
Patch for landing (10.02 KB, patch)
2021-06-21 01:12 PDT, Kimmo Kinnunen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kimmo Kinnunen 2021-06-18 01:00:07 PDT
Functions dispatched to WorkQueue are sometimes destroyed in the calling thread due to block refcounting

A lot of dispatched lambdas are written with the expectation that the destruction of the lambda is done in the called  thread.

See discussion for r270876 as a example where time was spent debugging this. 

See git grep "dispatch(.*WTFMove.*{.*}" for subset of call sites that expect the WorkQueue to behave in different way.
Comment 1 Kimmo Kinnunen 2021-06-18 01:30:32 PDT
Created attachment 431761 [details]
Patch
Comment 2 Antti Koivisto 2021-06-18 02:54:11 PDT
Comment on attachment 431761 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=431761&action=review

> Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp:35
> +namespace {
> +struct DispatchWorkItem {

Could use an empty line here.

> Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp:51
> +
> +

Extra empty line here.
Comment 3 Kimmo Kinnunen 2021-06-18 03:43:43 PDT
Created attachment 431766 [details]
Patch for landing
Comment 4 Kimmo Kinnunen 2021-06-21 01:12:37 PDT
Created attachment 431836 [details]
Patch for landing
Comment 5 EWS 2021-06-22 06:25:13 PDT
Committed r279115 (239032@main): <https://commits.webkit.org/239032@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 431836 [details].
Comment 6 Radar WebKit Bug Importer 2021-06-22 06:26:17 PDT
<rdar://problem/79611008>