Bug 170825 - x11-wm/xfce4-session takes segmentation fault while trying to save session
Summary: x11-wm/xfce4-session takes segmentation fault while trying to save session
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Olivier Duchateau
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-21 16:00 UTC by Greg Becker
Modified: 2013-03-03 16:57 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Becker 2012-08-21 16:00:24 UTC
xfce4 doesn't save sessions.  If you explicitly try to save a session via the "Session" tab in the "Session and Startup" control panel xfce4-session drops core and kills the X session.

Look like manager->session_file is NULL on entry to xfsm_manager_store_session():

$ gdb xfce4-session xfce4-session.core 
Core was generated by `xfce4-session'.
Program terminated with signal 11, Segmentation fault.

#0  0x0000000803cfd5d7 in strlen () from /lib/libc.so.7
[New Thread 808c07400 (LWP 100572/xfce4-session)]
(gdb) backt
#0  0x0000000803cfd5d7 in strlen () from /lib/libc.so.7
#1  0x000000080353c36b in g_string_chunk_insert_len ()
   from /usr/local/lib/libglib-2.0.so.0
#2  0x0000000801085468 in xfce_rc_simple_open ()
   from /usr/local/lib/libxfce4util.so.6
#3  0x0000000801083a6d in xfce_rc_simple_open ()
   from /usr/local/lib/libxfce4util.so.6
#4  0x0000000000419d6e in xfsm_manager_store_session (manager=0x808c4c800)
    at xfsm-manager.c:1609
#5  0x0000000000419b61 in xfsm_manager_complete_saveyourself (
    manager=0x808c4c800) at xfsm-manager.c:1524
#6  0x000000000041954a in xfsm_manager_save_yourself_done (
    manager=0x808c4c800, client=0x808c13630, success=1) at xfsm-manager.c:1280
#7  0x00000000004101fa in sm_save_yourself_done (sms_conn=0x808c41d00, 
    client_data=0x808c13630, success=1) at sm-layer.c:304
#8  0x0000000800c61086 in _SmsProcessMessage () from /usr/local/lib/libSM.so.6
#9  0x0000000800e73c30 in IceProcessMessages () from /usr/local/lib/libICE.so.6
#10 0x000000000040e9e2 in ice_process_messages (channel=0x808cbaa00, 
    condition=G_IO_IN, user_data=0x808e9c6d0) at ice-layer.c:111
#11 0x00000008035198b3 in g_main_context_dispatch ()
   from /usr/local/lib/libglib-2.0.so.0
#12 0x000000080351d8d2 in g_main_context_prepare ()
   from /usr/local/lib/libglib-2.0.so.0
#13 0x000000080351dcc5 in g_main_loop_run ()
   from /usr/local/lib/libglib-2.0.so.0
#14 0x000000080160e303 in gtk_main () from /usr/local/lib/libgtk-x11-2.0.so.0
#15 0x000000000040f8b5 in main (argc=1, argv=0x7fffffffd028) at main.c:308
(gdb) f 4
#4  0x0000000000419d6e in xfsm_manager_store_session (manager=0x808c4c800)
    at xfsm-manager.c:1609
1609	  rc = xfce_rc_simple_open (manager->session_file, FALSE);
(gdb) p manager.session_file
$1 = (gchar *) 0x0

(gdb) set print pretty
(gdb) p *manager
$3 = {
  parent = {
    g_type_instance = {
      g_class = 0x808cbd880
    }, 
    ref_count = 1, 
    qdata = 0x808c42700
  }, 
  state = XFSM_MANAGER_CHECKPOINT, 
  shutdown_type = XFSM_SHUTDOWN_LOGOUT, 
  shutdown_helper = 0x808c0b000, 
  session_chooser = 0, 
  session_name = 0x808c3a4b0 "Default", 
  session_file = 0x0, 
  checkpoint_session_name = 0x0, 
  start_at = 0, 
  compat_gnome = 0, 
  compat_kde = 0, 
  starting_properties = 0x808c42780, 
  pending_properties = 0x808c427a0, 
  restart_properties = 0x808c42760, 
  running_clients = 0x808c42740, 
  failsafe_mode = 1, 
  failsafe_clients = 0x808c42720, 
  die_timeout_id = 0, 
  session_bus = 0x808d1f288
}

I've got the non-stripped xfce4-session binary and core if anyone is interested.

Fix: 

You can prevent xfce4-session from dropping core by trapping the NULL session_file pointer and returning, but upon return to the X session from the console the screen is black and the screeen never redraws.
How-To-Repeat: Fresh install of FreeBSD 9, updated to latest stable.
Ports updated to latest.

Got to the "Session" tab in the "Session and Startup" control panel and click the "Save Session" button.
Comment 1 Edwin Groothuis freebsd_committer 2012-08-21 16:49:48 UTC
Responsible Changed
From-To: freebsd-ports-bugs->freebsd-xfce

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Olivier Duchateau 2013-02-18 21:49:56 UTC
Sorry, for long overdue. Could you test these 2 patches:

- http://people.freebsd.org/~olivierd/patches/xfce4-panel-4.10.0_5.diff
- http://people.freebsd.org/~olivierd/patches/xfce4-session-4.10.0_2.diff

Update first, x11-wm/xfce4-panel, then x11-wm/xfce4-session

-- 
olivier
Comment 3 Olivier Duchateau freebsd_committer 2013-03-03 08:05:05 UTC
Responsible Changed
From-To: freebsd-xfce->olivierd

I'll take it.
Comment 4 dfilter service freebsd_committer 2013-03-03 16:08:56 UTC
Author: olivierd
Date: Sun Mar  3 16:08:46 2013
New Revision: 313364
URL: http://svnweb.freebsd.org/changeset/ports/313364

Log:
  - Avoid coredump when we try to save session
  
  PR:	170825
  Submitted by:	Greg Becker
  Approved by:	rene, miwi (mentors, implicit)
  Obtained from:	project repository

Added:
  head/x11-wm/xfce4-panel/files/
  head/x11-wm/xfce4-panel/files/patch-plugins__actions__actions.c   (contents, props changed)
  head/x11-wm/xfce4-session/files/patch-xfce4-session-logout__main.c   (contents, props changed)
  head/x11-wm/xfce4-session/files/patch-xfce4-session__xfsm-manager.c   (contents, props changed)
Modified:
  head/x11-wm/xfce4-panel/Makefile
  head/x11-wm/xfce4-session/Makefile   (contents, props changed)

Modified: head/x11-wm/xfce4-panel/Makefile
==============================================================================
--- head/x11-wm/xfce4-panel/Makefile	Sun Mar  3 15:55:04 2013	(r313363)
+++ head/x11-wm/xfce4-panel/Makefile	Sun Mar  3 16:08:46 2013	(r313364)
@@ -4,7 +4,7 @@
 
 PORTNAME=	xfce4-panel
 PORTVERSION=	4.10.0
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	x11-wm xfce
 MASTER_SITES=	${MASTER_SITE_XFCE}
 DIST_SUBDIR=	xfce4

Added: head/x11-wm/xfce4-panel/files/patch-plugins__actions__actions.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11-wm/xfce4-panel/files/patch-plugins__actions__actions.c	Sun Mar  3 16:08:46 2013	(r313364)
@@ -0,0 +1,38 @@
+--- ./plugins/actions/actions.c.orig	2012-04-28 20:31:35.000000000 +0000
++++ ./plugins/actions/actions.c	2013-02-18 19:39:14.000000000 +0000
+@@ -705,7 +705,7 @@
+ 
+   if (timeout->time_left == 0)
+     {
+-      /* unattended shutdown, so don't allow apps to cancel shutdown */
++      /* unattended shutdown, don't save the session to avoid blocking the logout */
+       timeout->unattended = TRUE;
+ 
+       gtk_dialog_response (GTK_DIALOG (timeout->dialog),
+@@ -928,22 +928,22 @@
+     {
+     case ACTION_TYPE_LOGOUT:
+       succeed = actions_plugin_action_dbus_xfsm ("Logout", FALSE,
+-                                                 unattended, &error);
++                                                 !unattended, &error);
+       break;
+ 
+     case ACTION_TYPE_LOGOUT_DIALOG:
+       succeed = actions_plugin_action_dbus_xfsm ("Logout", TRUE,
+-                                                 unattended, &error);
++                                                 !unattended, &error);
+       break;
+ 
+     case ACTION_TYPE_RESTART:
+       succeed = actions_plugin_action_dbus_xfsm ("Restart", FALSE,
+-                                                 unattended, &error);
++                                                 !unattended, &error);
+       break;
+ 
+     case ACTION_TYPE_SHUTDOWN:
+       succeed = actions_plugin_action_dbus_xfsm ("Shutdown", FALSE,
+-                                                 unattended, &error);
++                                                 !unattended, &error);
+       break;
+ 
+     case ACTION_TYPE_HIBERNATE:

Modified: head/x11-wm/xfce4-session/Makefile
==============================================================================
--- head/x11-wm/xfce4-session/Makefile	Sun Mar  3 15:55:04 2013	(r313363)
+++ head/x11-wm/xfce4-session/Makefile	Sun Mar  3 16:08:46 2013	(r313364)
@@ -1,13 +1,10 @@
-# New ports collection makefile for:	xfce4-session
-# Date created:		2003-10-30
-# Whom:			Matt Lancereau <matt@rimasec.net>
-#
+# Created by: Matt Lancereau <matt@rimasec.net>
 # $FreeBSD$
 #
 
 PORTNAME=	xfce4-session
 PORTVERSION=	4.10.0
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	x11-wm xfce
 MASTER_SITES=	${MASTER_SITE_XFCE}
 DIST_SUBDIR=	xfce4
@@ -15,22 +12,21 @@ DIST_SUBDIR=	xfce4
 MAINTAINER=	xfce@FreeBSD.org
 COMMENT=	Xfce's session manager
 
-#CONFLICTS=	xfce4-utils-4.8.*
-
 BUILD_DEPENDS=	iceauth:${PORTSDIR}/x11/iceauth
 RUN_DEPENDS=	iceauth:${PORTSDIR}/x11/iceauth \
 		console-kit-daemon:${PORTSDIR}/sysutils/consolekit
-LIB_DEPENDS=	wnck-1.22:${PORTSDIR}/x11-toolkits/libwnck \
-		dbus-glib-1.2:${PORTSDIR}/devel/dbus-glib \
-		upower-glib.1:${PORTSDIR}/sysutils/upower \
-		polkit.2:${PORTSDIR}/sysutils/policykit
+LIB_DEPENDS=	wnck-1:${PORTSDIR}/x11-toolkits/libwnck \
+		dbus-glib-1:${PORTSDIR}/devel/dbus-glib \
+		upower-glib:${PORTSDIR}/sysutils/upower \
+		polkit:${PORTSDIR}/sysutils/policykit
 
 USE_AUTOTOOLS=	libtool
 GNU_CONFIGURE=	yes
 INSTALLS_ICONS=	yes
 USE_BZIP2=	yes
 USE_GMAKE=	yes
-USE_GNOME=	gnomehack gtk20 glib20 intltool intlhack pkgconfig desktopfileutils
+USE_GNOME=	gnomehack gtk20 glib20 intltool intlhack desktopfileutils
+USE_PKGCONFIG=	build
 USE_LDCONFIG=	yes
 USE_XFCE=	configenv libmenu libutil panel xfconf
 USE_XORG=	x11 sm ice
@@ -44,12 +40,12 @@ PKGMESSAGE=	${WRKDIR}/pkg-message
 
 OPTIONS_DEFINE=	NLS GNUPG
 
-.include <bsd.port.options.mk>
-
 MAN1=		xfce4-session.1 xfce4-session-logout.1
 
 PLIST_SUB=	VERSION="4.6"
 
+.include <bsd.port.options.mk>
+
 .if ${PORT_OPTIONS:MNLS}
 USE_GETTEXT=	yes
 CONFIGURE_ARGS+=	--enable-nls

Added: head/x11-wm/xfce4-session/files/patch-xfce4-session-logout__main.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11-wm/xfce4-session/files/patch-xfce4-session-logout__main.c	Sun Mar  3 16:08:46 2013	(r313364)
@@ -0,0 +1,38 @@
+--- ./xfce4-session-logout/main.c.orig	2012-04-28 20:43:27.000000000 +0000
++++ ./xfce4-session-logout/main.c	2013-02-18 19:18:45.000000000 +0000
+@@ -48,7 +48,7 @@
+ gboolean opt_reboot = FALSE;
+ gboolean opt_suspend = FALSE;
+ gboolean opt_hibernate = FALSE;
+-gboolean allow_save = FALSE;
++gboolean opt_fast = FALSE;
+ gboolean opt_version = FALSE;
+ 
+ enum
+@@ -83,7 +83,7 @@
+     N_("Hibernate without displaying the logout dialog"),
+     NULL
+   },
+-  { "fast", 'f', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &allow_save,
++  { "fast", 'f', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &opt_fast,
+     N_("Log out quickly; don't save the session"),
+     NULL
+   },
+@@ -123,6 +123,7 @@
+   gboolean         show_dialog;
+   gboolean         result = FALSE;
+   guint            shutdown_type;
++  gboolean         allow_save;
+ 
+   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+ 
+@@ -149,6 +150,9 @@
+       return EXIT_FAILURE;
+     }
+ 
++  /* save the session, unless fast is provided */
++  allow_save = !opt_fast;
++
+   /* create messsage */
+   proxy = dbus_g_proxy_new_for_name_owner (conn,
+                                            "org.xfce.SessionManager",

Added: head/x11-wm/xfce4-session/files/patch-xfce4-session__xfsm-manager.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11-wm/xfce4-session/files/patch-xfce4-session__xfsm-manager.c	Sun Mar  3 16:08:46 2013	(r313364)
@@ -0,0 +1,132 @@
+--- ./xfce4-session/xfsm-manager.c.orig	2012-04-28 20:43:27.000000000 +0000
++++ ./xfce4-session/xfsm-manager.c	2013-02-18 19:14:56.000000000 +0000
+@@ -98,6 +98,7 @@
+ 
+   XfsmShutdownType  shutdown_type;
+   XfsmShutdown     *shutdown_helper;
++  gboolean          save_session;
+ 
+   gboolean         session_chooser;
+   gchar           *session_name;
+@@ -230,6 +231,7 @@
+   manager->failsafe_mode = TRUE;
+   manager->shutdown_type = XFSM_SHUTDOWN_LOGOUT;
+   manager->shutdown_helper = xfsm_shutdown_get ();
++  manager->save_session = TRUE;
+ 
+   manager->pending_properties = g_queue_new ();
+   manager->starting_properties = g_queue_new ();
+@@ -989,7 +991,9 @@
+           XfsmClient *cl = lp->data;
+           if (xfsm_client_get_state (cl) == XFSM_CLIENT_INTERACTING)
+             {
+-              xfsm_client_set_state (cl, XFSM_CLIENT_WAITFORINTERACT);
++              /* a client is already interacting, so new client has to wait */
++              xfsm_client_set_state (client, XFSM_CLIENT_WAITFORINTERACT);
++              xfsm_manager_cancel_client_save_timeout(manager, client);
+               return;
+             }
+         }
+@@ -1138,44 +1142,47 @@
+         }
+     }
+ 
+-  if (!shutdown || shutdown_save)
++  /* don't save the session if shutting down without save */
++  manager->save_session = !shutdown || shutdown_save;
++
++  if (save_type == SmSaveBoth && !manager->save_session)
+     {
+-      xfsm_manager_set_state (manager,
+-                              shutdown
+-                              ? XFSM_MANAGER_SHUTDOWN
+-                              : XFSM_MANAGER_CHECKPOINT);
++      /* saving the session, so clients should
++       * (prompt to) save the user data only */
++      save_type = SmSaveGlobal;
++    }
+ 
+-      /* handle legacy applications first! */
+-      xfsm_legacy_perform_session_save ();
++  xfsm_manager_set_state (manager,
++                          shutdown
++                          ? XFSM_MANAGER_SHUTDOWN
++                          : XFSM_MANAGER_CHECKPOINT);
+ 
+-      for (lp = g_queue_peek_nth_link (manager->running_clients, 0);
+-           lp;
+-           lp = lp->next)
+-        {
+-          XfsmClient *client = lp->data;
+-          XfsmProperties *properties = xfsm_client_get_properties (client);
+-          const gchar *program;
++  /* handle legacy applications first! */
++  if (manager->save_session)
++      xfsm_legacy_perform_session_save ();
+ 
+-          /* xterm's session management is broken, so we won't
+-           * send a SAVE YOURSELF to xterms */
+-          program = xfsm_properties_get_string (properties, SmProgram);
+-          if (program != NULL && strcasecmp (program, "xterm") == 0)
+-            continue;
++  for (lp = g_queue_peek_nth_link (manager->running_clients, 0);
++       lp;
++       lp = lp->next)
++    {
++      XfsmClient *client = lp->data;
++      XfsmProperties *properties = xfsm_client_get_properties (client);
++      const gchar *program;
+ 
+-          if (xfsm_client_get_state (client) != XFSM_CLIENT_SAVINGLOCAL)
+-            {
+-              SmsSaveYourself (xfsm_client_get_sms_connection (client), save_type, shutdown,
+-                               interact_style, fast);
+-            }
++      /* xterm's session management is broken, so we won't
++       * send a SAVE YOURSELF to xterms */
++      program = xfsm_properties_get_string (properties, SmProgram);
++      if (program != NULL && strcasecmp (program, "xterm") == 0)
++        continue;
+ 
+-          xfsm_client_set_state (client, XFSM_CLIENT_SAVING);
+-          xfsm_manager_start_client_save_timeout (manager, client);
++      if (xfsm_client_get_state (client) != XFSM_CLIENT_SAVINGLOCAL)
++        {
++          SmsSaveYourself (xfsm_client_get_sms_connection (client), save_type, shutdown,
++                           interact_style, fast);
+         }
+-    }
+-  else
+-    {
+-      /* shutdown session without saving */
+-      xfsm_manager_perform_shutdown (manager);
++
++      xfsm_client_set_state (client, XFSM_CLIENT_SAVING);
++      xfsm_manager_start_client_save_timeout (manager, client);
+     }
+ }
+ 
+@@ -1249,7 +1256,12 @@
+                                  XfsmClient  *client,
+                                  gboolean     success)
+ {
+-  if (xfsm_client_get_state (client) != XFSM_CLIENT_SAVING && xfsm_client_get_state (client) != XFSM_CLIENT_SAVINGLOCAL)
++  /* In xfsm_manager_interact_done we send SmsShutdownCancelled to clients in
++     XFSM_CLIENT_WAITFORINTERACT state. They respond with SmcSaveYourselfDone
++     (xsmp_shutdown_cancelled in libxfce4ui library) so we allow it here. */
++  if (xfsm_client_get_state (client) != XFSM_CLIENT_SAVING &&
++      xfsm_client_get_state (client) != XFSM_CLIENT_SAVINGLOCAL &&
++      xfsm_client_get_state (client) != XFSM_CLIENT_WAITFORINTERACT)
+     {
+       xfsm_verbose ("Client Id = %s send SAVE YOURSELF DONE, while not being "
+                     "in save mode. Prepare to be nuked!\n",
+@@ -1521,7 +1533,8 @@
+   xfsm_verbose ("Manager finished SAVE YOURSELF, session data will be stored now.\n\n");
+ 
+   /* all clients done, store session data */
+-  xfsm_manager_store_session (manager);
++  if (manager->save_session)
++    xfsm_manager_store_session (manager);
+ 
+   if (manager->state == XFSM_MANAGER_CHECKPOINT)
+     {
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 5 Olivier Duchateau freebsd_committer 2013-03-03 16:57:53 UTC
State Changed
From-To: open->closed

Committed, with minor changes. Thanks!