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 792753 - g-c-c may crash if cups is disabled
g-c-c may crash if cups is disabled
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Printers
git master
Other Linux
: Normal normal
: ---
Assigned To: Marek Kašík
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-01-21 14:59 UTC by Mohammed Sadiq
Modified: 2018-02-09 12:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
printers: Make the cups connection test cancellable (7.29 KB, patch)
2018-01-23 17:37 UTC, Felipe Borges
none Details | Review
printers: Make the cups connection test cancellable (7.29 KB, patch)
2018-01-31 16:10 UTC, Felipe Borges
none Details | Review
printers: Make the cups connection test cancellable (7.28 KB, patch)
2018-02-09 11:34 UTC, Felipe Borges
committed Details | Review

Description Mohammed Sadiq 2018-01-21 14:59:21 UTC
If cups service is disabled, g-c-c may segfault.

How to reproduce:

0. Stop cups service:
   sudo systemctl stop cups
1. Open g-c-c
2. Search for "disp" and click on the Display panel item

Result:
g-c-c segfaults

gdb backtrace:

[New Thread 0x7fffb8ea3700 (LWP 24548)]

Thread 1 "gnome-control-c" received signal SIGSEGV, Segmentation fault.
0x000055555560caa0 in connection_test_cb (source_object=0x555555dc3e20, result=0x7fffa8002c40, user_data=0x555556ae15b0)
    at ../../../../../../Main/Software/src/gnome/gnome-control-center/panels/printers/cc-printers-panel.c:1088
1088	      priv->cups_status_check_id =
(gdb) thread apply all bt full

Thread 9 (Thread 0x7fffb8ea3700 (LWP 24548))

  • #0 syscall
    at ../sysdeps/unix/sysv/linux/x86_64/syscall.S line 38
  • #1 g_cond_wait_until
    at /home/sadiq/jhbuild/checkout/glib/glib/gthread-posix.c line 1449
  • #2 g_async_queue_pop_intern_unlocked
    at /home/sadiq/jhbuild/checkout/glib/glib/gasyncqueue.c line 422
  • #3 g_async_queue_timeout_pop_unlocked
    at /home/sadiq/jhbuild/checkout/glib/glib/gasyncqueue.c line 570
  • #4 g_thread_pool_wait_for_new_task
    at /home/sadiq/jhbuild/checkout/glib/glib/gthreadpool.c line 262
  • #5 g_thread_pool_thread_proxy
    at /home/sadiq/jhbuild/checkout/glib/glib/gthreadpool.c line 296
  • #6 g_thread_proxy
    at /home/sadiq/jhbuild/checkout/glib/glib/gthread.c line 784
  • #7 start_thread
    at pthread_create.c line 465
  • #8 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 95

Thread 7 (Thread 0x7fffb96a4700 (LWP 24546))

  • #0 syscall
    at ../sysdeps/unix/sysv/linux/x86_64/syscall.S line 38
  • #1 g_cond_wait_until
    at /home/sadiq/jhbuild/checkout/glib/glib/gthread-posix.c line 1449
  • #2 g_async_queue_pop_intern_unlocked
    at /home/sadiq/jhbuild/checkout/glib/glib/gasyncqueue.c line 422
  • #3 g_async_queue_timeout_pop_unlocked
    at /home/sadiq/jhbuild/checkout/glib/glib/gasyncqueue.c line 570
  • #4 g_thread_pool_wait_for_new_task
    at /home/sadiq/jhbuild/checkout/glib/glib/gthreadpool.c line 262
  • #5 g_thread_pool_thread_proxy
    at /home/sadiq/jhbuild/checkout/glib/glib/gthreadpool.c line 296
  • #6 g_thread_proxy
    at /home/sadiq/jhbuild/checkout/glib/glib/gthread.c line 784
  • #7 start_thread
    at pthread_create.c line 465
  • #8 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 95

Thread 5 (Thread 0x7fffbbfff700 (LWP 24304))

  • #0 syscall
    at ../sysdeps/unix/sysv/linux/x86_64/syscall.S line 38
  • #1 g_cond_wait_until
    at /home/sadiq/jhbuild/checkout/glib/glib/gthread-posix.c line 1449
  • #2 g_async_queue_pop_intern_unlocked
    at /home/sadiq/jhbuild/checkout/glib/glib/gasyncqueue.c line 422
  • #3 g_async_queue_timeout_pop_unlocked
    at /home/sadiq/jhbuild/checkout/glib/glib/gasyncqueue.c line 570
  • #4 g_thread_pool_wait_for_new_task
    at /home/sadiq/jhbuild/checkout/glib/glib/gthreadpool.c line 262
  • #5 g_thread_pool_thread_proxy
    at /home/sadiq/jhbuild/checkout/glib/glib/gthreadpool.c line 296
  • #6 g_thread_proxy
    at /home/sadiq/jhbuild/checkout/glib/glib/gthread.c line 784
  • #7 start_thread
    at pthread_create.c line 465
  • #8 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 95

Thread 1 (Thread 0x7ffff7f37b00 (LWP 24147))

  • #0 connection_test_cb
    at ../../../../../../Main/Software/src/gnome/gnome-control-center/panels/printers/cc-printers-panel.c line 1088
  • #1 g_task_return_now
    at /home/sadiq/jhbuild/checkout/glib/gio/gtask.c line 1148
  • #2 complete_in_idle_cb
    at /home/sadiq/jhbuild/checkout/glib/gio/gtask.c line 1162
  • #3 g_idle_dispatch
    at /home/sadiq/jhbuild/checkout/glib/glib/gmain.c line 5558
  • #4 g_main_dispatch
    at /home/sadiq/jhbuild/checkout/glib/glib/gmain.c line 3200
  • #5 g_main_context_dispatch
    at /home/sadiq/jhbuild/checkout/glib/glib/gmain.c line 3853
  • #6 g_main_context_iterate
    at /home/sadiq/jhbuild/checkout/glib/glib/gmain.c line 3926
  • #7 g_main_context_iteration
    at /home/sadiq/jhbuild/checkout/glib/glib/gmain.c line 3987
  • #8 g_application_run
    at /home/sadiq/jhbuild/checkout/glib/gio/gapplication.c line 2482
  • #9 main
    at ../../../../../../Main/Software/src/gnome/gnome-control-center/shell/main.c line 57

Comment 1 Felipe Borges 2018-01-23 17:37:39 UTC
Created attachment 367326 [details] [review]
printers: Make the cups connection test cancellable

Currently gnome-control-center could crash whenever a connection
test is interrupted by the disposal of the Printers panel.

Searching in the g-c-c shell for any query that could match the
Printers panel would instantiate the CcPrintersPanel class. Since
we perform a connection test to the printing server as soon as this
object is created, a fast disposal of the panel (by choosing another
search result) would cause the whole application to crash.
Comment 2 Georges Basile Stavracas Neto 2018-01-26 01:28:03 UTC
Review of attachment 367326 [details] [review]:

A few minor comments below.

I think, however, there is another problem here: when the CcPanelList page changes (e.g. goes from the main page to the Devices page), it always activated the first panel. This is true as well when Control Center is initialized with a panel as a parameter, and we end up loading the Wi-Fi panel, then quickly switch to the other panel.

This might be a separate bug, but it definitely needs to be fixed as well. It doesn't, however, invalidate the need to have a more robust Printers panel, and that's why I think this patch is still necessary and highly appreciated =)

::: panels/printers/cc-printers-panel.c
@@ +1084,3 @@
   gboolean                success;
   PpCups                 *cups = PP_CUPS (source_object);
+  GError                 *error = NULL;

Is there any reason to not use g_autptr(GError) here?

@@ +1095,3 @@
+        {
+          g_warning ("Could not test connection: %s", error->message);
+        }

Doesn't need the curly braces.

::: panels/printers/pp-cups.c
@@ +118,3 @@
+    {
+      g_task_return_boolean (task, http != NULL);
+    }

Doesn't need the curly braces
Comment 3 Felipe Borges 2018-01-26 08:03:32 UTC
(In reply to Georges Basile Stavracas Neto from comment #2)
> Review of attachment 367326 [details] [review] [review]:
> 
> A few minor comments below.
> 
> I think, however, there is another problem here: when the CcPanelList page
> changes (e.g. goes from the main page to the Devices page), it always
> activated the first panel. This is true as well when Control Center is
> initialized with a panel as a parameter, and we end up loading the Wi-Fi
> panel, then quickly switch to the other panel.
> 
> This might be a separate bug, but it definitely needs to be fixed as well.
> It doesn't, however, invalidate the need to have a more robust Printers
> panel, and that's why I think this patch is still necessary and highly
> appreciated =)
> 
> ::: panels/printers/cc-printers-panel.c
> @@ +1084,3 @@
>    gboolean                success;
>    PpCups                 *cups = PP_CUPS (source_object);
> +  GError                 *error = NULL;
> 
> Is there any reason to not use g_autptr(GError) here?

We haven't used it yet in the Printers panel. If Marek is cool with that, sure.

> 
> @@ +1095,3 @@
> +        {
> +          g_warning ("Could not test connection: %s", error->message);
> +        }
> 
> Doesn't need the curly braces.

same, we usually use braces pretty much everywhere in Printers.
Comment 4 Georges Basile Stavracas Neto 2018-01-26 12:54:36 UTC
(In reply to Felipe Borges from comment #3)

> > 
> > @@ +1095,3 @@
> > +        {
> > +          g_warning ("Could not test connection: %s", error->message);
> > +        }
> > 
> > Doesn't need the curly braces.
> 
> same, we usually use braces pretty much everywhere in Printers.

Oh, that's fine then.
Comment 5 Marek Kašík 2018-01-31 15:56:51 UTC
(In reply to Felipe Borges from comment #3)
> (In reply to Georges Basile Stavracas Neto from comment #2)
> > Review of attachment 367326 [details] [review] [review] [review]:
> >
> > Is there any reason to not use g_autptr(GError) here?
> 
> We haven't used it yet in the Printers panel. If Marek is cool with that,
> sure.

Hi, yes, it is ok with me and thank you for the patch.
Comment 6 Felipe Borges 2018-01-31 16:10:09 UTC
Created attachment 367718 [details] [review]
printers: Make the cups connection test cancellable

Currently gnome-control-center could crash whenever a connection
test is interrupted by the disposal of the Printers panel.

Searching in the g-c-c shell for any query that could match the
Printers panel would instantiate the CcPrintersPanel class. Since
we perform a connection test to the printing server as soon as this
object is created, a fast disposal of the panel (by choosing another
search result) would cause the whole application to crash.
Comment 7 Felipe Borges 2018-01-31 16:10:45 UTC
(In reply to Marek Kašík from comment #5)
> (In reply to Felipe Borges from comment #3)
> > (In reply to Georges Basile Stavracas Neto from comment #2)
> > > Review of attachment 367326 [details] [review] [review] [review] [review]:
> > >
> > > Is there any reason to not use g_autptr(GError) here?
> > 
> > We haven't used it yet in the Printers panel. If Marek is cool with that,
> > sure.
> 
> Hi, yes, it is ok with me and thank you for the patch.

Thanks. I will be using g_autoptr from now on for newly introduced objects.
Comment 8 Marek Kašík 2018-02-09 10:33:52 UTC
Review of attachment 367718 [details] [review]:

Thank you for the patch. There are just 2 things which need to change.

::: panels/printers/cc-printers-panel.c
@@ +831,3 @@
   widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "main-vbox");
   if (priv->num_dests == 0 && !priv->new_printer_name)
+    pp_cups_connection_test_async (g_object_ref (cups), NULL, set_current_page, widget);

You have to change this because it does not apply now (s/widget/self/).

@@ +1097,3 @@
+        }
+
+      g_error_free (error);

You have to remove this because it crashes g-c-c.
Comment 9 Marek Kašík 2018-02-09 10:36:25 UTC
Btw, I was not able to reproduce the original issue.
Comment 10 Felipe Borges 2018-02-09 11:34:31 UTC
Created attachment 368178 [details] [review]
printers: Make the cups connection test cancellable

Currently gnome-control-center could crash whenever a connection
test is interrupted by the disposal of the Printers panel.

Searching in the g-c-c shell for any query that could match the
Printers panel would instantiate the CcPrintersPanel class. Since
we perform a connection test to the printing server as soon as this
object is created, a fast disposal of the panel (by choosing another
search result) would cause the whole application to crash.
Comment 11 Marek Kašík 2018-02-09 12:05:18 UTC
Review of attachment 368178 [details] [review]:

Thank you for the patch. Push it to relevant branches please.
Comment 12 Felipe Borges 2018-02-09 12:32:55 UTC
Attachment 368178 [details] pushed as 2ff5cfd - printers: Make the cups connection test cancellable