From 342509559fc3d437b009d2f08dceb36aa19a55e2 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 20 Apr 2015 16:45:43 +0200 Subject: [PATCH] device: make sure NMDevice doesn't vanish halfway through applying configuration It could be that the device was removed and the default route manager holds the last reference: Breakpoint 1, dispose (object=0x90e710 [NMDeviceTun]) at devices/nm-device.c:8588 8588 NMDevice *self = NM_DEVICE (object); (gdb) bt #0 0x000000000045d24e in dispose (object=0x90e710 [NMDeviceTun]) at devices/nm-device.c:8588 #1 0x00007ffff4d29b7c in g_object_unref (_object=0x90e710) at gobject.c:3133 #2 0x00000000004b0a61 in _entry_at_idx_remove (entry=) at nm-default-route-manager.c:192 #3 0x00000000004b0a61 in _entry_at_idx_remove (vtable=, self=, entry_idx=) at nm-default-route-manager.c:638 #4 0x00000000004adb51 in _ipx_update_default_route (vtable=0x7b1850 , self=0x7da610 [NMDefaultRouteManager], source=) at nm-default-route-manager.c:814 #5 0x0000000000459ccb in nm_device_set_ip6_config (self=0x90e710 [NMDeviceTun], new_config=, commit=, reason=) at devices/nm-device.c:6213 #6 0x0000000000450c92 in ip6_config_merge_and_apply (self=0x90e710 [NMDeviceTun], commit=0, out_reason=0x0) at devices/nm-device.c:3670 #7 0x0000000000452d06 in update_ip_config (self=0x90e710 [NMDeviceTun], initial=) at devices/nm-device.c:6915 #8 0x000000000046253e in queued_ip_config_change (user_data=) at devices/nm-device.c:6945 #9 0x00007ffff4a257fb in g_main_context_dispatch (context=0x7ca3e0) at gmain.c:3111 #10 0x00007ffff4a257fb in g_main_context_dispatch (context=context@entry=0x7ca3e0) at gmain.c:3710 #11 0x00007ffff4a25b98 in g_main_context_iterate (context=0x7ca3e0, block=block@entry=1, dispatch=dispatch@entry=1, self=) at gmain.c:3781 #12 0x00007ffff4a25ec2 in g_main_loop_run (loop=0x7ca4a0) at gmain.c:3975 #13 0x0000000000444bbe in main (argc=, argv=) at main.c:486 (gdb) Program received signal SIGTRAP, Trace/breakpoint trap. g_logv (log_domain=0x7ffff4d4f164 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=, args=args@entry=0x7fffffffd5b0) at gmessages.c:1046 1046 g_private_set (&g_log_depth, GUINT_TO_POINTER (depth)); (gdb) bt #0 0x00007ffff4a2c970 in g_logv (log_domain=0x7ffff4d4f164 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=, args=args@entry=0x7fffffffd5b0) at gmessages.c:1046 #1 0x00007ffff4a2cbaf in g_log (log_domain=log_domain@entry=0x7ffff4d4f164 "GLib-GObject", log_level=log_level@entry=G_LOG_LEVEL_WARNING, format=format@entry=0x7ffff4d563b0 "invalid unclassed pointer in cast to '%s'") at gmessages.c:1079 #2 0x00007ffff4d481f9 in g_type_check_instance_cast (type_instance=0x90e710, iface_type=) at gtype.c:4030 #3 0x0000000000459ceb in nm_device_set_ip6_config (self=0x90e710, new_config=, commit=, reason=0x0) at devices/nm-device.c:6217 #4 0x0000000000450c92 in ip6_config_merge_and_apply (self=0x90e710, commit=0, out_reason=0x0) at devices/nm-device.c:3670 #5 0x0000000000452d06 in update_ip_config (self=0x90e710, initial=) at devices/nm-device.c:6915 #6 0x000000000046253e in queued_ip_config_change (user_data=) at devices/nm-device.c:6945 #7 0x00007ffff4a257fb in g_main_context_dispatch (context=0x7ca3e0) at gmain.c:3111 #8 0x00007ffff4a257fb in g_main_context_dispatch (context=context@entry=0x7ca3e0) at gmain.c:3710 #9 0x00007ffff4a25b98 in g_main_context_iterate (context=0x7ca3e0, block=block@entry=1, dispatch=dispatch@entry=1, self=) at gmain.c:3781 #10 0x00007ffff4a25ec2 in g_main_loop_run (loop=0x7ca4a0) at gmain.c:3975 #11 0x0000000000444bbe in main (argc=, argv=) at main.c:486 (gdb) https://bugzilla.gnome.org/show_bug.cgi?id=748193 (cherry picked from commit 6fba9fd2e55216ba12c77e4567c48d79289cc9b7) --- src/devices/nm-device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index f88f6f4936..2badb825a1 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -6782,6 +6782,7 @@ queued_ip_config_change (gpointer user_data) return TRUE; priv->queued_ip_config_id = 0; + g_object_ref (self); update_ip_config (self, FALSE); /* If no IPv6 link-local address exists but other addresses do then we @@ -6792,6 +6793,8 @@ queued_ip_config_change (gpointer user_data) if (priv->ip6_config && nm_ip6_config_get_num_addresses (priv->ip6_config)) check_and_add_ipv6ll_addr (self); + g_object_unref (self); + return FALSE; }