Title: [266145] trunk/Source/WTF
Revision
266145
Author
[email protected]
Date
2020-08-25 14:51:00 -0700 (Tue, 25 Aug 2020)

Log Message

[Win] Assert failure under RunLoop::RunLoop
https://bugs.webkit.org/show_bug.cgi?id=215812

Reviewed by Brent Fulgham.

The assert 'ASSERT(::IsWindow(m_runLoopMessageWindow))' under RunLoop::RunLoop will fail if the JSC API JSGlobalContextCreate*()
is being called by a client before WTF::initializeMainThread() has been called. The assertion fails because the method
RunLoop::registerRunLoopMessageWindowClass() has not been called yet, since it is only called when initializing the main thread.
This patch addresses this issue by making sure the window class has been registered before being referenced in RunLoop::RunLoopl
The method call is also removed from the main thread initialization, since the window class is only used in RunLoop::RunLoop,
making it sufficient to only be registered there. Also change the debug assert to a release assert, so we can catch similar
issues in release builds.

* wtf/win/MainThreadWin.cpp:
(WTF::initializeMainThreadPlatform):
* wtf/win/RunLoopWin.cpp:
(WTF::RunLoop::registerRunLoopMessageWindowClass):
(WTF::RunLoop::RunLoop):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (266144 => 266145)


--- trunk/Source/WTF/ChangeLog	2020-08-25 21:43:14 UTC (rev 266144)
+++ trunk/Source/WTF/ChangeLog	2020-08-25 21:51:00 UTC (rev 266145)
@@ -1,3 +1,24 @@
+2020-08-25  Per Arne Vollan  <[email protected]>
+
+        [Win] Assert failure under RunLoop::RunLoop
+        https://bugs.webkit.org/show_bug.cgi?id=215812
+
+        Reviewed by Brent Fulgham.
+
+        The assert 'ASSERT(::IsWindow(m_runLoopMessageWindow))' under RunLoop::RunLoop will fail if the JSC API JSGlobalContextCreate*()
+        is being called by a client before WTF::initializeMainThread() has been called. The assertion fails because the method
+        RunLoop::registerRunLoopMessageWindowClass() has not been called yet, since it is only called when initializing the main thread.
+        This patch addresses this issue by making sure the window class has been registered before being referenced in RunLoop::RunLoopl
+        The method call is also removed from the main thread initialization, since the window class is only used in RunLoop::RunLoop,
+        making it sufficient to only be registered there. Also change the debug assert to a release assert, so we can catch similar
+        issues in release builds.
+
+        * wtf/win/MainThreadWin.cpp:
+        (WTF::initializeMainThreadPlatform):
+        * wtf/win/RunLoopWin.cpp:
+        (WTF::RunLoop::registerRunLoopMessageWindowClass):
+        (WTF::RunLoop::RunLoop):
+
 2020-08-24  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Implement rendering frames timeline panel for GTK+ port

Modified: trunk/Source/WTF/wtf/win/MainThreadWin.cpp (266144 => 266145)


--- trunk/Source/WTF/wtf/win/MainThreadWin.cpp	2020-08-25 21:43:14 UTC (rev 266144)
+++ trunk/Source/WTF/wtf/win/MainThreadWin.cpp	2020-08-25 21:51:00 UTC (rev 266145)
@@ -43,7 +43,6 @@
 {
     mainThread = Thread::currentID();
     Thread::initializeCurrentThreadInternal("Main Thread");
-    RunLoop::registerRunLoopMessageWindowClass();
 }
 
 bool isMainThread()

Modified: trunk/Source/WTF/wtf/win/RunLoopWin.cpp (266144 => 266145)


--- trunk/Source/WTF/wtf/win/RunLoopWin.cpp	2020-08-25 21:43:14 UTC (rev 266144)
+++ trunk/Source/WTF/wtf/win/RunLoopWin.cpp	2020-08-25 21:51:00 UTC (rev 266145)
@@ -99,19 +99,23 @@
 
 void RunLoop::registerRunLoopMessageWindowClass()
 {
-    WNDCLASS windowClass = { };
-    windowClass.lpfnWndProc     = RunLoop::RunLoopWndProc;
-    windowClass.cbWndExtra      = sizeof(RunLoop*);
-    windowClass.lpszClassName   = kRunLoopMessageWindowClassName;
-    bool result = ::RegisterClass(&windowClass);
-    RELEASE_ASSERT(result);
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        WNDCLASS windowClass = { };
+        windowClass.lpfnWndProc     = RunLoop::RunLoopWndProc;
+        windowClass.cbWndExtra      = sizeof(RunLoop*);
+        windowClass.lpszClassName   = kRunLoopMessageWindowClassName;
+        bool result = ::RegisterClass(&windowClass);
+        RELEASE_ASSERT(result);
+    });
 }
 
 RunLoop::RunLoop()
 {
+    registerRunLoopMessageWindowClass();
     m_runLoopMessageWindow = ::CreateWindow(kRunLoopMessageWindowClassName, nullptr, 0,
         CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_MESSAGE, nullptr, nullptr, this);
-    ASSERT(::IsWindow(m_runLoopMessageWindow));
+    RELEASE_ASSERT(::IsWindow(m_runLoopMessageWindow));
 }
 
 RunLoop::~RunLoop()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to