Bug 226255 - Stop using UncheckedLock in WTF::AutomaticThread
Summary: Stop using UncheckedLock in WTF::AutomaticThread
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-25 19:35 PDT by Chris Dumez
Modified: 2021-05-26 09:47 PDT (History)
14 users (show)

See Also:


Attachments
Patch (20.20 KB, patch)
2021-05-25 19:41 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (22.66 KB, patch)
2021-05-25 20:09 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (22.69 KB, patch)
2021-05-25 20:13 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (23.08 KB, patch)
2021-05-26 08:11 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (20.91 KB, patch)
2021-05-26 09:42 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2021-05-25 19:35:23 PDT
Stop using UncheckedLock in WTF::AutomaticThread as it is being phased out in favor of Lock, which supports Clang thread safety analysis.
Comment 1 Chris Dumez 2021-05-25 19:41:19 PDT
Created attachment 429725 [details]
Patch
Comment 2 Chris Dumez 2021-05-25 20:09:16 PDT
Created attachment 429726 [details]
Patch
Comment 3 Chris Dumez 2021-05-25 20:13:00 PDT
Created attachment 429727 [details]
Patch
Comment 4 Keith Miller 2021-05-26 08:04:08 PDT
Comment on attachment 429727 [details]
Patch

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

> Source/WTF/wtf/ParallelHelperPool.cpp:189
> +        assertIsHeld(*m_pool.m_lock);

Why not just annotate the poll function? Or does this only work for locks that are a member of the same class as the method?
Comment 5 Chris Dumez 2021-05-26 08:06:40 PDT
Comment on attachment 429727 [details]
Patch

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

>> Source/WTF/wtf/ParallelHelperPool.cpp:189
>> +        assertIsHeld(*m_pool.m_lock);
> 
> Why not just annotate the poll function? Or does this only work for locks that are a member of the same class as the method?

I'll try. I think I already tried that and it didn't work but I don't really remember why.
Comment 6 Chris Dumez 2021-05-26 08:11:37 PDT
Created attachment 429759 [details]
Patch
Comment 7 Chris Dumez 2021-05-26 08:12:10 PDT
(In reply to Keith Miller from comment #4)
> Comment on attachment 429727 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=429727&action=review
> 
> > Source/WTF/wtf/ParallelHelperPool.cpp:189
> > +        assertIsHeld(*m_pool.m_lock);
> 
> Why not just annotate the poll function? Or does this only work for locks
> that are a member of the same class as the method?

Looks like it builds without the assertIsHeld() and the annotation. Made the change.
Comment 8 Keith Miller 2021-05-26 08:19:17 PDT
(In reply to Chris Dumez from comment #7)
> (In reply to Keith Miller from comment #4)
> > Comment on attachment 429727 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=429727&action=review
> > 
> > > Source/WTF/wtf/ParallelHelperPool.cpp:189
> > > +        assertIsHeld(*m_pool.m_lock);
> > 
> > Why not just annotate the poll function? Or does this only work for locks
> > that are a member of the same class as the method?
> 
> Looks like it builds without the assertIsHeld() and the annotation. Made the
> change.

Interesting, I'm surprised it's able to prove that no function changes the m_pool ref. Or maybe it makes the assumption that those values are constant? I guess the same thing would apply to the Box<Lock> that we pass to the AtomaticThread too.
Comment 9 Chris Dumez 2021-05-26 09:42:46 PDT
Created attachment 429767 [details]
Patch
Comment 10 Chris Dumez 2021-05-26 09:46:45 PDT
Comment on attachment 429767 [details]
Patch

Clearing flags on attachment: 429767

Committed r278087 (238164@main): <https://commits.webkit.org/238164@main>
Comment 11 Chris Dumez 2021-05-26 09:46:48 PDT
All reviewed patches have been landed.  Closing bug.
Comment 12 Radar WebKit Bug Importer 2021-05-26 09:47:18 PDT
<rdar://problem/78517626>