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 166852 - gnome_vfs_cancellation_cancel should be callable from any thread
gnome_vfs_cancellation_cancel should be callable from any thread
Status: RESOLVED FIXED
Product: gnome-vfs
Classification: Deprecated
Component: Async operations
cvs (head)
Other All
: Normal normal
: ---
Assigned To: gnome-vfs maintainers
gnome-vfs maintainers
Depends on:
Blocks:
 
 
Reported: 2005-02-09 21:05 UTC by Thomas Fitzsimmons
Modified: 2005-02-16 13:28 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
Test program! (1.26 KB, text/x-csrc)
2005-02-10 15:50 UTC, Christian Kellner
  Details
Proposed patch! (2.03 KB, patch)
2005-02-10 15:53 UTC, Christian Kellner
none Details | Review
Second try! (2.02 KB, patch)
2005-02-10 16:23 UTC, Christian Kellner
needs-work Details | Review

Description Thomas Fitzsimmons 2005-02-09 21:05:41 UTC
Please describe the problem:
I'm implementing the AWT FileDialog in libgcj using GtkFileChooserDialog.  The
AWT is multi-threaded by design and as a result it may call
gnome_vfs_cancellation_cancel in a thread other than the one gnome-vfs was
initialized in.  This causes GNOME_VFS_ASSERT_PRIMARY_THREAD to fail, crashing
the program.  In the context of GTK, this can be reproduced by running a
GtkFileChooserDialog in a thread other than the glib main loop and attempting to
switch directories.

Steps to reproduce:
1. run GtkFileChooserDialog in a thread other than the glib main loop
2. attempt to change directories within the chooser

Actual results:
the directory should change

Expected results:
the program crashes with an assertion failure

Does this happen every time?
yes

Other information:
Comment 1 Christian Kellner 2005-02-10 15:50:54 UTC
Created attachment 37294 [details]
Test program!

I am not 100% sure the threading stuff is done correctly!
Comment 2 Christian Kellner 2005-02-10 15:53:27 UTC
Created attachment 37295 [details] [review]
Proposed patch!

If not in the main thread, schedule a call from the main thread via g_idle_add.
Tested with the program above!
Comment 3 Christian Kellner 2005-02-10 16:23:34 UTC
Created attachment 37299 [details] [review]
Second try!

I added GNOME_VFS_ASSERT_PRIMARY_THREAD back to really make sure that we call
gnome_vfs_cancellation_cancel_internal from the main thread!
Comment 4 Christian Kellner 2005-02-10 16:57:59 UTC
Comment on attachment 37299 [details] [review]
Second try!

Can't commit there might be races with this patch. We better make cancellation
threadsafe!
Comment 5 Alexander Larsson 2005-02-16 13:28:57 UTC
The latest version of gnome-vfs has this sort of fixed. It allows cancellation
from multiple threads, but requires some work from the app to handle a possible
race. I've also fixed this race in the gnome-vfs file selector backend.