Bug 140998

Summary: [GTK] Runtime critical warnings sometimes at start up when using the network process
Product: WebKit Reporter: Carlos Garcia Campos <cgarcia>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, gns, svillar, zan
Priority: P2 Keywords: Gtk
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch zan: review+

Description Carlos Garcia Campos 2015-01-28 07:42:37 PST
(WebKitWebProcess:1594): GLib-CRITICAL **: g_main_loop_run: assertion 'loop != NULL' failed

(WebKitWebProcess:1617): GLib-CRITICAL **: g_main_loop_run: assertion 'loop != NULL' failed

(WebKitWebProcess:1609): GLib-CRITICAL **: g_main_loop_run: assertion 'loop != NULL' failed

(WebKitWebProcess:1613): GLib-CRITICAL **: g_main_loop_run: assertion 'loop != NULL' failed

(WebKitWebProcess:1638): GLib-CRITICAL **: g_main_loop_run: assertion 'loop != NULL' failed

This is caused by the CustomProtocolManager work queue theread. This WorkQueue is created when the CustomProtocolManager object is constructed, but destroyed when it's initialized when the UI process asks to use the network process. In this case, sometimes happens that the work queue thread that runs the main loop is executed once the object has been destroyed and the main loop pointer is null.
Comment 1 Carlos Garcia Campos 2015-01-28 07:46:04 PST
Created attachment 245542 [details]
Patch

Detach the worker thread when the work queue is destroyed, right before deleting the main loop
Comment 2 WebKit Commit Bot 2015-01-28 07:47:39 PST
Attachment 245542 [details] did not pass style-queue:


ERROR: Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp:55:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Zan Dobersek 2015-01-29 01:58:57 PST
Comment on attachment 245542 [details]
Patch

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

> Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp:55
> -    m_workQueueThread = createThread(reinterpret_cast<WTF::ThreadFunction>(&WorkQueue::startWorkQueueThread), this, threadName);
> +    m_workQueueThread = createThread(threadName, [this] { g_main_loop_run(m_eventLoop.get()); });

WorkQueue is ref-counted. This should probably pass a RefPtr protector into the lambda.
Comment 4 Carlos Garcia Campos 2015-01-29 23:23:05 PST
Committed r179395: <http://trac.webkit.org/changeset/179395>