Bug 15686 - GtkLauncher aborts on launch due to uninitialized threading subsystem
Summary: GtkLauncher aborts on launch due to uninitialized threading subsystem
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 523.x (Safari 3)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2007-10-25 05:53 PDT by m. dietrich
Modified: 2007-10-25 11:32 PDT (History)
2 users (show)

See Also:

Fix, initialize thread support early as possible (2.71 KB, patch)
2007-10-25 11:28 PDT, Alp Toker
beidson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description m. dietrich 2007-10-25 05:53:23 PDT
initialization fails with the message:

GLib-ERROR **: The thread system is not yet initialized. aborting...

glib's threading must be initilized before database stuff is initialized. i put 

if (!g_thread_supported ()) g_thread_init (NULL);

into WebKitTools/GtkLauncher/main.cpp but maybe  webkit_init() in WebKit/gtk/Api/webkitgtkglobal.cpp is a better place.
Comment 1 Mark Rowe (bdash) 2007-10-25 05:56:53 PDT
What is happening here is that webkit_init calls DatabaseTracker::tracker to retrieve the DatabaseTracker singleton to set the database path.  The DatabaseTracker constructor allocates a SQLDatabase, which in turn allocates a Mutex.  All of this happens without WebCore calling initializeThreading.  The Gtk port could work around this by calling initializeThreading from webkit_init, but WebCore should be doing this itself before doing anything thread-related (this includes allocating mutexes).
Comment 2 Mark Rowe (bdash) 2007-10-25 05:58:16 PDT
Copying Brady as he's done a lot of the work on the threading support in WebCore.  Brady, do you have any idea how to ensure that initializeThreading is always called at the appropriate times?  The two locations that it is currently called from seem quite arbitrary.
Comment 3 Alp Toker 2007-10-25 08:17:09 PDT
Database support has been disabled in r27047 pending a fix for this bug. GtkLauncher should work again.
Comment 4 Brady Eidson 2007-10-25 09:17:58 PDT
Actually, there's already an abstraction for this in WebCore.  Check out threading.h - 

void initializeThreading();

It seems that GTK already hooked into that in r26864

initializeThreading() is called at any point a secondary thread might be kicked off.  Currently this include the IconDatabase c'tor and the Database c'tor.  GTK's impl in ThreadingGTK.cpp seems to do exactly what you say needs to be done -
if (!g_thread_supported ()) g_thread_init (NULL);

So in other words, I'm surprised this isn't working already.

Comment 5 Brady Eidson 2007-10-25 09:19:25 PDT
Per Mark's comment of "the two locations now seem quite arbritrary" - perhaps the specific locations can be tweaked somewhat, but I like the idea of initializing threading *only* when a secondary thread might be kicked off.

If a client doesn't use the icon database and never visits a page with client-side databases, there's no reason they should init threading
Comment 6 Alp Toker 2007-10-25 11:28:03 PDT
Created attachment 16861 [details]
Fix, initialize thread support early as possible
Comment 7 Brady Eidson 2007-10-25 11:29:47 PDT
Comment on attachment 16861 [details]
Fix, initialize thread support early as possible

I'm still curious why the initialize-on-the-spot didn't work, but this seems reasonable.
Comment 8 Alp Toker 2007-10-25 11:32:12 PDT
Fixed in r27050.