GNOME Bugzilla – Bug 314533
race condition in idle_finished_loading_cb causing assertion failure
Last modified: 2011-02-04 16:19:18 UTC
Steps to reproduce: I was seeing this intermittent assertion failure when running a test program on the GNU Classpath GTK AWT peers: Gtk-ERROR **: file /home/fitzsim/sources/gtk+/gtk/gtkfilechooserdefault.c: line 5136 (pending_select_paths_process): assertion failed: (impl->browse_files_model != NULL) (The AWT's design is inherently multi-threaded) The failure condition was this: AWT_MAIN_THREAD GTK_MAIN_THREAD gdk_threads_enter() gtk_widget_show(dialog) [...] gtkfilechooserdefault.c:set_list_model [...] impl->browse_files_model = NULL; gtkfilesystemmodel.c:idle_finished_loading_cb [...] gtkfilechooserdefault.c:pending_select_paths_process [...] g_assert (impl->browse_files_model != NULL); Since idle_finished_loading_cb is run in the idle part of the GTK main thread, it is run without the GDK lock held. But seeing as it is modifying internal state of a GTK widget, it should acquire the GDK lock. The attached patch fixes the problem. Stack trace: Other information:
The text box wrapped the trace. Here it is presented differently: AWT_MAIN_THREAD runs: gdk_threads_enter() gtk_widget_show(dialog) [...] gtkfilechooserdefault.c:set_list_model [...] impl->browse_files_model = NULL; <context switch> GTK_MAIN_THREAD runs: gtkfilesystemmodel.c:idle_finished_loading_cb [...] gtkfilechooserdefault.c:pending_select_paths_process [...] g_assert (impl->browse_files_model != NULL);
Created attachment 51359 [details] [review] fix locking in idle_finished_loading_cb
I committed this patch to HEAD and to the gtk-2-8 branch.