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 562452 - Ensure we return G_IO_ERROR_CANCELLED if cancelling g_simple_async_result_run_in_thread
Ensure we return G_IO_ERROR_CANCELLED if cancelling g_simple_async_result_run...
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.18.x
Other Linux
: Normal critical
: ---
Assigned To: Milan Crha
gtkdev
Depends on:
Blocks:
 
 
Reported: 2008-11-27 14:07 UTC by Milan Crha
Modified: 2008-12-10 14:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed glib patch (1.53 KB, patch)
2008-12-09 13:43 UTC, Milan Crha
none Details | Review

Description Milan Crha 2008-11-27 14:07:04 UTC
Opened file chooser in SciTE (some text editor), deep in directory structure, hold the Ctrl and hitting quickly Arrow Up to get to root dir. It crashed somewhere in the middle.

Package: gtk2-2.14.4-3.fc10.i386

Trace caught by bug buddy:

System: Linux 2.6.27.5-117.fc10.i686 #1 SMP Tue Nov 18 12:19:59 EST 2008 i686
X Vendor: The X.Org Foundation
X Vendor Release: 10503000
Selinux: Enforcing
Accessibility: Disabled
GTK+ Theme: Nodoka
Icon Theme: Crux

Memory status: size: 78139392 vsize: 78139392 resident: 22540288 share: 10686464 rss: 22540288 rss_rlim: 18446744073709551615
CPU usage: start_time: 1227793801 rtime: 182 utime: 174 stime: 8 cutime:0 cstime: 0 timeout: 0 it_real_value: 0 frequency: 100

Backtrace was generated from '/usr/bin/SciTE'

(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 0xb7f06720 (LWP 3322)]
[New Thread 0xb5effb90 (LWP 3324)]
0x00110416 in __kernel_vsyscall ()

Thread 1 (Thread 0xb7f06720 (LWP 3322))

  • #0 __kernel_vsyscall
  • #1 waitpid
    from /lib/libpthread.so.0
  • #2 g_spawn_sync
    from /lib/libglib-2.0.so.0
  • #3 g_spawn_command_line_sync
    from /lib/libglib-2.0.so.0
  • #4 ??
    from /usr/lib/gtk-2.0/modules/libgnomebreakpad.so
  • #5 ??
    from /usr/lib/gtk-2.0/modules/libgnomebreakpad.so
  • #6 ??
    from /usr/lib/gtk-2.0/modules/libgnomebreakpad.so
  • #7 <signal handler called>
  • #8 enumerator_files_callback
    at gtkfilesystem.c line 1330
  • #9 ??
    from /lib/libgio-2.0.so.0
  • #10 g_simple_async_result_complete
    from /lib/libgio-2.0.so.0
  • #11 ??
    from /lib/libgio-2.0.so.0
  • #12 ??
    from /lib/libglib-2.0.so.0
  • #13 g_main_context_dispatch
    from /lib/libglib-2.0.so.0
  • #14 ??
    from /lib/libglib-2.0.so.0
  • #15 g_main_loop_run
    from /lib/libglib-2.0.so.0
  • #16 IA__gtk_dialog_run
    at gtkdialog.c line 1068
  • #17 SciTEGTK::OpenDialog
  • #18 SciTEBase::MenuCommand
  • #19 SciTEGTK::Command
  • #20 gtk_item_factory_callback_marshal
    at gtkitemfactory.c line 188
  • #21 g_cclosure_marshal_VOID__VOID
    from /lib/libgobject-2.0.so.0
  • #22 g_closure_invoke
    from /lib/libgobject-2.0.so.0
  • #23 ??
    from /lib/libgobject-2.0.so.0
  • #24 g_signal_emit_valist
    from /lib/libgobject-2.0.so.0
  • #25 g_signal_emit
    from /lib/libgobject-2.0.so.0
  • #26 closure_accel_activate
    at gtkwidget.c line 4151
  • #27 g_closure_invoke
    from /lib/libgobject-2.0.so.0
  • #28 ??
    from /lib/libgobject-2.0.so.0
  • #29 g_signal_emit_valist
    from /lib/libgobject-2.0.so.0
  • #30 g_signal_emit
    from /lib/libgobject-2.0.so.0
  • #31 IA__gtk_accel_group_activate
    at gtkaccelgroup.c line 858
  • #32 IA__gtk_accel_groups_activate
    at gtkaccelgroup.c line 896
  • #33 IA__gtk_window_activate_key
    at gtkwindow.c line 8087
  • #34 gtk_window_key_press_event
    at gtkwindow.c line 4995
  • #35 _gtk_marshal_BOOLEAN__BOXED
    at gtkmarshalers.c line 84
  • #36 ??
    from /lib/libgobject-2.0.so.0
  • #37 g_closure_invoke
    from /lib/libgobject-2.0.so.0
  • #38 ??
    from /lib/libgobject-2.0.so.0
  • #39 g_signal_emit_valist
    from /lib/libgobject-2.0.so.0
  • #40 g_signal_emit
    from /lib/libgobject-2.0.so.0
  • #41 gtk_widget_event_internal
    at gtkwidget.c line 4745
  • #42 IA__gtk_propagate_event
    at gtkmain.c line 2365
  • #43 IA__gtk_main_do_event
    at gtkmain.c line 1596
  • #44 gdk_event_dispatch
    at gdkevents-x11.c line 2365
  • #45 g_main_context_dispatch
    from /lib/libglib-2.0.so.0
  • #46 ??
    from /lib/libglib-2.0.so.0
  • #47 g_main_loop_run
    from /lib/libglib-2.0.so.0
  • #48 IA__gtk_main
    at gtkmain.c line 1200
  • #49 SciTEGTK::Run
  • #50 main
The program is running.  Quit anyway (and detach it)? (y or n) [answered Y; input not from terminal]


----------- .xsession-errors ---------------------
** (nm-applet:2775): WARNING **: No connections defined
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
Window manager warning: Attempt to perform window operation 20 on window none when operation 20 on none already in effect
(SciTE:3322): GLib-GObject-WARNING **: instance of invalid non-instantiatable type `(null)'
--------------------------------------------------
Comment 1 Milan Crha 2008-12-09 13:37:37 UTC
moving to glib/gio, the fix is supposed to come there.
Comment 2 Milan Crha 2008-12-09 13:43:25 UTC
Created attachment 124268 [details] [review]
proposed glib patch

for glib/gio;
Comment 3 Alexander Larsson 2008-12-10 12:08:31 UTC
That is wrong. The func call should set the result of the operation, whether it is a successful result or an error (including a cancelled error).

With you patch you either set the cancelled error twice, or the func returns a different result but we override that with an error causing possible leaks or whatnot.

Cancellation is inherently racy, and will always be, so you can never be guaranteed that you get a cancelled error if you call g_cancellable_cancel().

What exact problem did you have that caused this patch?
Comment 4 Alexander Larsson 2008-12-10 12:55:18 UTC
Actually, it looks like there should be no problem with leaking results, so if the error setters were fixed to free existing errors first we could avoid any leaks.

And, in theory there is a limited case where we can be race-free, if you're cancelling an async operation and the cancelling happens from the main thread. However, for that to be race free we would need to check is_cancelled in right before calling out to the user in the main thread (i.e. g_simple_async_result_complete), otherwise there is still a race between returning from run_in_thread and calling back on the main thread.

The problem is that by the time we get back to g_simple_async_result_complete we no longer have the GCancellable around.
Comment 5 Alexander Larsson 2008-12-10 13:25:45 UTC
2008-12-10  Alexander Larsson  <alexl@redhat.com>

	Bug 562452 - Ensure we return G_IO_ERROR_CANCELLED if cancelling
	g_simple_async_result_run_in_thread
	
        * gsimpleasyncresult.c:
	Make g_simple_async_result_run_in_thread check cancellation before
	calling out to the user in the callback. This means we guarantee
	reporting cancels of async operations from the main threads, which
	is probably more in line with what users expect.
	
	Note that there are still no such guarantees for cancelling sync
	operations or cancelling async operation from outside the main
	thread.

Comment 6 Milan Crha 2008-12-10 14:23:38 UTC
Thanks, it works great.