After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 314533 - race condition in idle_finished_loading_cb causing assertion failure
race condition in idle_finished_loading_cb causing assertion failure
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.8.x
Other All
: High critical
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2005-08-26 03:22 UTC by Thomas Fitzsimmons
Modified: 2011-02-04 16:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix locking in idle_finished_loading_cb (685 bytes, patch)
2005-08-26 03:29 UTC, Thomas Fitzsimmons
none Details | Review

Description Thomas Fitzsimmons 2005-08-26 03:22:29 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:
Comment 1 Thomas Fitzsimmons 2005-08-26 03:26:55 UTC
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);
Comment 2 Thomas Fitzsimmons 2005-08-26 03:29:44 UTC
Created attachment 51359 [details] [review]
fix locking in idle_finished_loading_cb
Comment 3 Thomas Fitzsimmons 2005-08-26 03:55:16 UTC
I committed this patch to HEAD and to the gtk-2-8 branch.