Bug 121883 - [Windows] Refactor RuntimeEnabledFeatures as a Singleton to prevent crashes caused by cross-DLL boundary access
Summary: [Windows] Refactor RuntimeEnabledFeatures as a Singleton to prevent crashes c...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-24 17:21 PDT by Brent Fulgham
Modified: 2013-10-29 08:38 PDT (History)
12 users (show)

See Also:


Attachments
Patch (99.21 KB, patch)
2013-09-24 18:33 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (125.19 KB, patch)
2013-09-25 10:43 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Updated after removal of HTMLContentElement.cpp (124.28 KB, patch)
2013-09-25 10:57 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (124.41 KB, patch)
2013-09-25 11:19 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Removed offending WebCore.exp.in entries (126.61 KB, patch)
2013-09-25 12:05 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Removed typo from WebCore.exp.in (126.42 KB, patch)
2013-09-25 13:39 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Updated with missing symbol in WebCore.exp.in (126.48 KB, patch)
2013-09-25 14:15 PDT, Brent Fulgham
jer.noble: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2013-09-24 17:21:31 PDT
The RuntimeEnabledFeatures pseudo-singleton class has a number of inline getters and setters. When these are used to access the static members of the class across a DLL boundary, we are encountering crashes under Windows.

While this seems to be behavior specific to Visual Studio, it is not a good design and should be refactored to act as a 'real' Singleton object to avoid non-deterministic behavior for reading/writing this memory.
Comment 1 Brent Fulgham 2013-09-24 18:33:21 PDT
Created attachment 212529 [details]
Patch
Comment 2 Early Warning System Bot 2013-09-24 18:41:34 PDT
Comment on attachment 212529 [details]
Patch

Attachment 212529 [details] did not pass qt-ews (qt):
Output: http://webkit-queues.appspot.com/results/2174074
Comment 3 Early Warning System Bot 2013-09-24 18:43:07 PDT
Comment on attachment 212529 [details]
Patch

Attachment 212529 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/2165004
Comment 4 EFL EWS Bot 2013-09-24 18:50:39 PDT
Comment on attachment 212529 [details]
Patch

Attachment 212529 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/2162073
Comment 5 Build Bot 2013-09-24 19:16:54 PDT
Comment on attachment 212529 [details]
Patch

Attachment 212529 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/2217006
Comment 6 Build Bot 2013-09-24 19:23:24 PDT
Comment on attachment 212529 [details]
Patch

Attachment 212529 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/2169077
Comment 7 kov's GTK+ EWS bot 2013-09-24 19:42:24 PDT
Comment on attachment 212529 [details]
Patch

Attachment 212529 [details] did not pass gtk-ews (gtk):
Output: http://webkit-queues.appspot.com/results/2174085
Comment 8 EFL EWS Bot 2013-09-24 19:44:40 PDT
Comment on attachment 212529 [details]
Patch

Attachment 212529 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/2190067
Comment 9 Jer Noble 2013-09-25 08:30:32 PDT
Comment on attachment 212529 [details]
Patch

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

Awesome. Just a few nits.

> Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp:142
> +RuntimeEnabledFeatures& RuntimeEnabledFeatures::sharedRuntimeEnabledFeatures()

RuntimeEnabledFeatures::sharedRuntimeEnabledFeatures() seems a bit redundant.  How about RuntimeEnabledFeatures::sharedFeatures()?

> Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h:45
>  class RuntimeEnabledFeatures {
>  public:

You should add WTF_MAKE_NONCOPYABLE(RuntimeEnabledFeatures) here now that we have an instance.

> Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h:317
> +    bool isLocalStorageEnabled;
> +    bool isSessionStorageEnabled;
> +    bool isWebkitNotificationsEnabled;
> +    bool isApplicationCacheEnabled;
> +    bool isDataTransferItemsEnabled;
> +    bool isGeolocationEnabled;
> +    bool isIndexedDBEnabled;
> +    bool isTouchEnabled;
> +    bool isDeviceMotionEnabled;
> +    bool isDeviceOrientationEnabled;
> +    bool isSpeechInputEnabled;
> +    bool isCanvasPathEnabled;
> +    bool isCSSExclusionsEnabled;
> +    bool isCSSShapesEnabled;
> +    bool isCSSRegionsEnabled;
> +    bool isCSSCompositingEnabled;
> +    bool isLangAttributeAwareFormControlUIEnabled;

While we're cleaning up bad coding style, we should really make all these variables conform to WebKit Coding Style, with m_ prefixes for each.
Comment 10 Brent Fulgham 2013-09-25 10:43:41 PDT
Created attachment 212601 [details]
Patch
Comment 11 Brent Fulgham 2013-09-25 10:57:04 PDT
Created attachment 212604 [details]
Updated after removal of HTMLContentElement.cpp
Comment 12 Brent Fulgham 2013-09-25 11:01:37 PDT
Once this patch is in place we can reactivate CSS Shapes on Windows (i.e., revert Bug 121879).
Comment 13 Early Warning System Bot 2013-09-25 11:07:29 PDT
Comment on attachment 212604 [details]
Updated after removal of HTMLContentElement.cpp

Attachment 212604 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/2212053
Comment 14 Early Warning System Bot 2013-09-25 11:13:08 PDT
Comment on attachment 212604 [details]
Updated after removal of HTMLContentElement.cpp

Attachment 212604 [details] did not pass qt-ews (qt):
Output: http://webkit-queues.appspot.com/results/2217054
Comment 15 Brent Fulgham 2013-09-25 11:19:07 PDT
Created attachment 212608 [details]
Patch
Comment 16 Build Bot 2013-09-25 11:51:26 PDT
Comment on attachment 212608 [details]
Patch

Attachment 212608 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/2217061
Comment 17 Brent Fulgham 2013-09-25 12:05:19 PDT
Created attachment 212612 [details]
Removed offending WebCore.exp.in entries
Comment 18 Brent Fulgham 2013-09-25 12:26:10 PDT
Comment on attachment 212612 [details]
Removed offending WebCore.exp.in entries

Watching the mac/mac-wk2 bots. They will probably fail one more time to show me the symbol I need to add to WebCore.exp.in to support the new Singleton object.
Comment 19 Build Bot 2013-09-25 12:45:11 PDT
Comment on attachment 212612 [details]
Removed offending WebCore.exp.in entries

Attachment 212612 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/2224054
Comment 20 Build Bot 2013-09-25 13:08:18 PDT
Comment on attachment 212612 [details]
Removed offending WebCore.exp.in entries

Attachment 212612 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/2220014
Comment 21 Brent Fulgham 2013-09-25 13:39:01 PDT
Created attachment 212620 [details]
Removed typo from WebCore.exp.in
Comment 22 Build Bot 2013-09-25 14:11:32 PDT
Comment on attachment 212620 [details]
Removed typo from WebCore.exp.in

Attachment 212620 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/2240010
Comment 23 Brent Fulgham 2013-09-25 14:15:24 PDT
Created attachment 212625 [details]
Updated with missing symbol in WebCore.exp.in
Comment 24 Jer Noble 2013-09-25 14:18:40 PDT
Comment on attachment 212625 [details]
Updated with missing symbol in WebCore.exp.in

r=me
Comment 25 Brent Fulgham 2013-09-25 15:18:22 PDT
Committed r156424: <http://trac.webkit.org/changeset/156424>
Comment 26 Csaba Osztrogonác 2013-10-29 08:38:08 PDT
Comment on attachment 212625 [details]
Updated with missing symbol in WebCore.exp.in

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

> Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h:419
> +#ifndef CLASS_IF_GCC
> +#if COMPILER(GCC)
> +#define CLASS_IF_GCC class
> +#else
> +#define CLASS_IF_GCC
> +#endif
> +#endif
> +    friend CLASS_IF_GCC NeverDestroyed<RuntimeEnabledFeatures>;

Sooooooo ugly. :-/

Is it a well-known MSVC bug? It seems we ran into the same bug in https://bugs.webkit.org/show_bug.cgi?id=123442
But I prefer a general fix for it instead of adding workarounds everywhere.