Bug 217271

Summary: std::once_flag must be allocated in static storage
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: New BugsAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, darin, ddkilzer, ews-watchlist, glenn, jbedard, mark.lam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch mark.lam: review+

Description Yusuke Suzuki 2020-10-02 19:44:17 PDT
std::once_flag must be allocated in static storage
Comment 1 Yusuke Suzuki 2020-10-02 19:48:21 PDT
Created attachment 410407 [details]
Patch
Comment 2 Mark Lam 2020-10-02 20:19:21 PDT
Comment on attachment 410407 [details]
Patch

r=me
Comment 3 Mark Lam 2020-10-02 20:24:41 PDT
Comment on attachment 410407 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        Since std::once_flag is an usual variable, this does not prevent us from calling it multiple times.

Did you mean "If the std::once_flag is a non-static variable, it will not prevent ..."?
Comment 4 Yusuke Suzuki 2020-10-02 23:00:30 PDT
Committed r267917: <https://trac.webkit.org/changeset/267917>
Comment 5 Yusuke Suzuki 2020-10-02 23:00:52 PDT
Comment on attachment 410407 [details]
Patch

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

>> Source/WebCore/ChangeLog:8
>> +        Since std::once_flag is an usual variable, this does not prevent us from calling it multiple times.
> 
> Did you mean "If the std::once_flag is a non-static variable, it will not prevent ..."?

Fixed.
Comment 6 Radar WebKit Bug Importer 2020-10-02 23:01:15 PDT
<rdar://problem/69908537>
Comment 7 Darin Adler 2020-10-03 10:36:23 PDT
Comment on attachment 410407 [details]
Patch

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

> Source/WebCore/platform/text/TextCodecSingleByte.cpp:180
> -    std::once_flag once;
> +    static std::once_flag once;

Oops, guess it was me who made this mistake. Thank you for fixing it!
Comment 8 David Kilzer (:ddkilzer) 2020-10-05 09:26:05 PDT
Sadly, I believe this is caught by the clang static analyzer as well.