linuxmint / cinnamon-session

The Cinnamon session manager
GNU General Public License v2.0
26 stars 36 forks source link

Inhibitor activation crashes the session due to null pointer in ConsoleKit backend #124

Closed vishwin closed 5 years ago

vishwin commented 5 years ago
 * 4.0.0
 * FreeBSD 13-CURRENT
 * i915kms
 * amd64

Issue When the inhibitor is activated in any way, the session immediately crashes. This is due to a null pointer (see backtrace) in system. Looking through the source, it appears that csm_consolekit_new() is not correctly setting the pointer.

(e)logind backend is probably not susceptible to this.

Steps to reproduce Easiest is to switch power management off in the inhibitor applet. But any program that "adds" the inhibitor during normal operation will also do.

Expected behaviour Inhibit the screensaver or screen from turning off, without total session crashing.

Other information Example backtrace, where Nemo spawns a delete confirmation dialog:

(lldb) bt
* thread #1, name = 'cinnamon-session', stop reason = signal SIGSEGV
  * frame #0: 0x000000000023dcb7 cinnamon-session`csm_system_add_inhibitor(system=0x0000000000000000, id="/org/gnome/SessionManager/Inhibitor1", flag=CSM_INHIBITOR_FLAG_LOGOUT) at csm-system.c:145
    frame #1: 0x00000000002364dc cinnamon-session`on_store_inhibitor_added(store=0x0000000804269a40, id="/org/gnome/SessionManager/Inhibitor1", manager=0x000000080422d2a0) at csm-manager.c:2583
    frame #2: 0x000000080033ceb3 libgobject-2.0.so.0`g_cclosure_marshal_VOID__STRING(closure=0x00000008042324d0, return_value=0x0000000000000000, n_param_values=2, param_values=0x00007fffffffdac0, invocation_hint=0x00007fffffffda60, marshal_data=0x0000000000000000) at gmarshal.c:1754
    frame #3: 0x0000000800337511 libgobject-2.0.so.0`g_closure_invoke(closure=0x00000008042324d0, return_value=0x0000000000000000, n_param_values=2, param_values=0x00007fffffffdac0, invocation_hint=0x00007fffffffda60) at gclosure.c:810
    frame #4: 0x0000000800358ae3 libgobject-2.0.so.0`signal_emit_unlocked_R(node=0x000000080424bf80, detail=0, instance=0x0000000804269a40, emission_return=0x0000000000000000, instance_and_params=0x00007fffffffdac0) at gsignal.c:3635
    frame #5: 0x000000080035a492 libgobject-2.0.so.0`g_signal_emit_valist(instance=0x0000000804269a40, signal_id=169, detail=0, var_args=0x00007fffffffe1f0) at gsignal.c:3391
    frame #6: 0x000000080035acd7 libgobject-2.0.so.0`g_signal_emit(instance=0x0000000804269a40, signal_id=169, detail=0) at gsignal.c:3447
    frame #7: 0x000000000023cdf5 cinnamon-session`csm_store_add(store=0x0000000804269a40, id="/org/gnome/SessionManager/Inhibitor1", object=0x00000008049ce7a0) at csm-store.c:248
    frame #8: 0x00000000002315be cinnamon-session`csm_manager_inhibit(manager=0x000000080422d2a0, app_id="org.x.editor", toplevel_xid=109052149, reason="There are unsaved documents", flags=1, context=0x0000000804736be0) at csm-manager.c:3704
    frame #9: 0x000000000022ee41 cinnamon-session`dbus_glib_marshal_csm_manager_VOID__STRING_UINT_STRING_UINT_POINTER(closure=0x00007fffffffe540, return_value=0x0000000000000000, n_param_values=6, param_values=0x0000000804875580, invocation_hint=0x0000000000000000, marshal_data=0x0000000000231230) at csm-manager-glue.h:399
    frame #10: 0x00000008002a8214 libdbus-glib-1.so.2`object_registration_message + 3620
    frame #11: 0x00000008002f6564 libdbus-1.so.3`_dbus_object_tree_dispatch_and_unlock + 276
    frame #12: 0x00000008002e641f libdbus-1.so.3`dbus_connection_dispatch + 975
    frame #13: 0x00000008002b7b3a libdbus-glib-1.so.2`message_queue_dispatch + 26
    frame #14: 0x000000080045b5d3 libglib-2.0.so.0`g_main_dispatch(context=0x00000008024b1180) at gmain.c:3182
    frame #15: 0x000000080045b420 libglib-2.0.so.0`g_main_context_dispatch(context=0x00000008024b1180) at gmain.c:3847
    frame #16: 0x000000080045b96e libglib-2.0.so.0`g_main_context_iterate(context=0x00000008024b1180, block=1, dispatch=1, self=0x00000008042694a0) at gmain.c:3920
    frame #17: 0x000000080045be2e libglib-2.0.so.0`g_main_loop_run(loop=0x00000008024aa6d0) at gmain.c:4116
    frame #18: 0x0000000800d13e1b libgtk-3.so.0`gtk_main + 75
    frame #19: 0x0000000000244cfa cinnamon-session`main(argc=1, argv=0x00007fffffffeab8) at main.c:381
    frame #20: 0x000000000021b114 cinnamon-session`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:76
leigh123linux commented 5 years ago

Don't expect a fix any time soon as we don't actively use or support consolekit.

vishwin commented 5 years ago

I figured ConsoleKit support wasn't exactly a high priority anyway.

It should also be mentioned that I'm not using a display manager at all; everything goes through startx.

Upon some further investigation, however, this may not have that much to do with ConsoleKit. I'm also noticing that an incorrect $DBUS_SESSION_BUS_ADDRESS is set and used during the session, and the incorrect variable persists on subsequent session restarts. Mentioning this because the actual inhibitor firing itself takes place in DBus.

Side note, this also prevents cinnamon-looking-glass from launching at all.

vishwin commented 5 years ago

The $DBUS_SESSION_BUS_ADDRESS inconsistency is pilot error, precipitated by shells running within tmux holding onto an environment from a prior Cinnamon session. So disregard everything I said about DBus. cinnamon-looking-glass functions fine once the session bus address got correctly oriented.

My investigation turns back to everything surrounding csm_system_add_inhibitor() and csm_consolekit_new(), among other things.

vishwin commented 5 years ago

At the end of the day, this is entirely pilot error.

Since FreeBSD doesn't have a logind port (yet?), when org.cinnamon.desktop.session.session-manager-uses-logind and org.cinnamon.desktop.session.settings-daemon-uses-logind are set to true (by default), csm_get_system() will not branch to ConsoleKit even if the system pointer remains null (because logind doesn't exist). For our port, we will carry a local patch to change the defaults of the two aforementioned dconf keys to false.