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 788716 - Segfault in load_wifi_devices()
Segfault in load_wifi_devices()
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Network
3.26.x
Other Linux
: Normal normal
: ---
Assigned To: Control-Center Maintainers
Control-Center Maintainers
: 789030 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2017-10-09 13:11 UTC by Sebastien Bacher
Modified: 2017-11-02 09:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
don't segfault when there is no device listed (783 bytes, patch)
2017-10-09 13:24 UTC, Sebastien Bacher
none Details | Review
network: Avoid crashing if NM reports no devices or no connections (1.85 KB, patch)
2017-11-01 15:47 UTC, Rui Matos
committed Details | Review

Description Sebastien Bacher 2017-10-09 13:11:47 UTC
The bug has been reported against 3.26.1-0ubuntu1 on https://bugs.launchpad.net/ubuntu/+source/gnome-control-center/+bug/1722186



  • #0 load_wifi_devices
    at cc-wifi-panel.c line 144
  • #1 cc_wifi_panel_init
    at cc-wifi-panel.c line 623
  • #2 g_type_create_instance
    at ../../../../gobject/gtype.c line 1866
  • #3 g_object_new_internal
    at ../../../../gobject/gobject.c line 1781
  • #4 g_object_new_valist
    at ../../../../gobject/gobject.c line 2104
  • #5 g_object_new
    at ../../../../gobject/gobject.c line 1624
  • #6 cc_panel_loader_load_by_name
    at cc-panel-loader.c line 243
  • #7 activate_panel
    at cc-window.c line 130

Comment 1 Sebastien Bacher 2017-10-09 13:13:39 UTC
the corresponding code is 

"  devices = nm_client_get_devices (self->client);

  /* Cold-plug existing devices */
  for (i = 0; i < devices->len; i++)"

nm_client_get_devices can return NULL though, other panels do check for that which this one doesn't before trying to access ->len
Comment 2 Sebastien Bacher 2017-10-09 13:24:02 UTC
Created attachment 361187 [details] [review]
don't segfault when there is no device listed
Comment 3 Rui Matos 2017-11-01 15:32:57 UTC
Review of attachment 361187 [details] [review]:

sigh, I don't think this was a problem in the past so I think NM changed here and the documentation doesn't say this might return NULL, in fact, it says it returns an array that's owned by the library so there's no reason for it to be NULL but whatever better safe than sorrow

::: panels/network/cc-wifi-panel.c
@@ +143,3 @@
+  if (devices == NULL)
+    return;
+

we still need to call check_main_stack_page() below
Comment 4 Rui Matos 2017-11-01 15:47:47 UTC
Created attachment 362764 [details] [review]
network: Avoid crashing if NM reports no devices or no connections

Seems like NM changed behavior recently but, in any case, better safe
than sorry.
Comment 5 Rui Matos 2017-11-01 16:41:10 UTC
Attachment 362764 [details] pushed as cb4a7e1 - network: Avoid crashing if NM reports no devices or no connections
Comment 6 Rui Matos 2017-11-02 09:46:13 UTC
*** Bug 789030 has been marked as a duplicate of this bug. ***