WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
223013
[Cocoa] Make WebKit API Objective-C objects safe to release on non-main threads
https://bugs.webkit.org/show_bug.cgi?id=223013
Summary
[Cocoa] Make WebKit API Objective-C objects safe to release on non-main threads
Darin Adler
Reported
2021-03-09 18:31:18 PST
[Cocoa] Make WebKit API Objective-C objects safe to release on non-main threads
Attachments
Patch
(74.08 KB, patch)
2021-03-10 09:38 PST
,
Darin Adler
ggaren
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Darin Adler
Comment 1
2021-03-10 09:38:36 PST
Created
attachment 422840
[details]
Patch
Geoffrey Garen
Comment 2
2021-03-10 09:56:15 PST
Comment on
attachment 422840
[details]
Patch r=me
Chris Dumez
Comment 3
2021-03-10 09:58:36 PST
Comment on
attachment 422840
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=422840&action=review
> Source/WTF/wtf/MainThread.cpp:71 > +void ensureOnMainRunLoop(Function<void()>&& function)
Nice name, better than what I had suggested :)
Darin Adler
Comment 4
2021-03-10 11:58:40 PST
Committed
r274227
(
235138@main
): <
https://commits.webkit.org/235138@main
>
Radar WebKit Bug Importer
Comment 5
2021-03-10 11:59:19 PST
<
rdar://problem/75275804
>
Joshua Wise
Comment 6
2021-03-17 10:37:05 PDT
Hi Darin -- As someone who just tripped on a related issue recently, thanks much for thinking about this! Unfortunately, I don't think this makes releasing as safe as it appears to.
Bug 222336
has a reproducer that I think will crash even with this fix -- and
comment 6
in that bug describes why that crash occurs. Thanks -- joshua
mitz
Comment 7
2021-03-22 12:06:02 PDT
Have you considered using something like _OBJC_SUPPORTED_INLINE_REFCNT_WITH_DEALLOC2MAIN (see <
https://opensource.apple.com/source/objc4/objc4-493.11/runtime/objc-internal.h.auto.html
>) here? I believe that would account for cases like
bug 222336
.
Darin Adler
Comment 8
2021-03-22 12:17:56 PDT
I did not know about _OBJC_SUPPORTED_INLINE_REFCNT_WITH_DEALLOC2MAIN.
Joshua Wise
Comment 9
2021-03-31 00:58:49 PDT
I believe that `_OBJC_SUPPORTED_INLINE_REFCNT_LOGIC` is vulnerable to the same weak pointer race condition as
bug 222336
(though I have not tried it). The problem is that `_isDeallocating` causes a weak pointer to fail to store, but `dealloc` causes a weak pointer to be zeroed. Or, to put it another way, `dealloc2main` is not sufficient: `release2main` is necessary. But I, also, did not know about `_OBJC_SUPPORTED_INLINE_REFCNT_LOGIC`. I confess that I find it quite disconcerting that someone would believe this to be common enough of an idiom to make a macro for it, and even more disconcerting that that an invocation variant exists with `release2main == 0`. It is perhaps fitting that one of the only textual references to this on the web is from seven years ago on, of all places, the SomethingAwful forums.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug