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 400793 - first login after logout fails with CK
first login after logout fails with CK
Status: RESOLVED FIXED
Product: gdm
Classification: Core
Component: general
unspecified
Other Linux
: Normal major
: ---
Assigned To: GDM maintainers
GDM maintainers
Depends on:
Blocks:
 
 
Reported: 2007-01-25 21:28 UTC by William Jon McCann
Modified: 2007-02-05 05:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test patch (3.10 KB, patch)
2007-01-26 02:30 UTC, William Jon McCann
none Details | Review
patch (4.74 KB, patch)
2007-01-26 20:46 UTC, William Jon McCann
none Details | Review
patch (18.75 KB, patch)
2007-01-31 17:45 UTC, William Jon McCann
committed Details | Review

Description William Jon McCann 2007-01-25 21:28:34 UTC
I can confirm what Matthias noticed in bug 335786.

"I note some issue with a patched gdm 2.17.5: The first login attempt
after a logout fails (I see a vt switch, then I end up back at the gdm login),
but the next attempt succeeds."
Comment 1 William Jon McCann 2007-01-25 21:36:36 UTC


  • #0 __kernel_vsyscall
  • #1 raise
    from /lib/libc.so.6
  • #2 abort
    from /lib/libc.so.6
  • #3 IA__g_logv
  • #4 IA__g_log
  • #5 IA__g_assert_warning
    at gmessages.c line 552
  • #6 dbus_g_proxy_begin_call_internal
    at dbus-gproxy.c line 2123
  • #7 manager_begin_bus_call
    at dbus-gproxy.c line 1766
  • #8 dbus_g_proxy_manager_register
    at dbus-gproxy.c line 939
  • #9 dbus_g_proxy_constructor
    at dbus-gproxy.c line 1327
  • #10 IA__g_object_newv
    at gobject.c line 937
  • #11 IA__g_object_new_valist
    at gobject.c line 1022
  • #12 IA__g_object_new
    at gobject.c line 795
  • #13 dbus_g_proxy_new
    at dbus-gproxy.c line 1824
  • #14 open_ck_session
    at gdmconsolekit.c line 243
  • #15 gdm_slave_session_start
    at slave.c line 4319
  • #16 gdm_slave_run
    at slave.c line 1552
  • #17 gdm_slave_start
    at slave.c line 859
  • #18 gdm_display_manage
    at display.c line 322
  • #19 mainloop_sig_callback
    at gdm.c line 1097
  • #20 IA__g_main_context_dispatch
    at gmain.c line 2045
  • #21 g_main_context_iterate
    at gmain.c line 2677
  • #22 IA__g_main_loop_run
    at gmain.c line 2881
  • #23 main
    at gdm.c line 1790

Comment 2 William Jon McCann 2007-01-26 00:34:43 UTC
So, it looks like the trouble starts as the previous session ends and close_ck_session is called.  Then when the dbus connection is used again the assert is hit.  My guess is that one of the slave processes is closing fds and this is confusing dbus-glib.  Perhaps we should be using a private connection anyway but this seems to non-standard with the glib bindings.
Comment 3 William Jon McCann 2007-01-26 02:25:43 UTC
CloseSession fails with:
"Connection was disconnected before a reply was received"

If I patch dbus-glib to add a new function dbus_g_bus_get_private() then CloseSession still fails but the following open_ck_session works.
Comment 4 William Jon McCann 2007-01-26 02:30:43 UTC
Created attachment 81242 [details] [review]
test patch

This is the patch that I tested this with.  Of course this only works if dbus-glib is patched to add dbus_g_bus_get_private().

This does have to other parts that probably should be committed:
* a build fix for the greeter
* converting g_warnings to gdm_errors so they are logged

Since CloseSession still fails there is still a problem somewhere.  However, using a private connection is more failsafe and desirable either way...
Comment 5 Brian Cameron 2007-01-26 06:00:01 UTC
Could you get the needed dbus-glib patch upstream before I commit a fix for GDM?
Or find a way to fix the problem that doesn't require modifying dbus-glib?

Comment 6 William Jon McCann 2007-01-26 06:06:49 UTC
That patch was just a test not a fix.  Still trying to understand the problem.
Comment 7 William Jon McCann 2007-01-26 20:46:29 UTC
Created attachment 81292 [details] [review]
patch

Ok, first I needed to be able to get debug output from the dbus client side library.  So I "export DBUS_VERBOSE=1" in /etc/X11/prefdm (also could have been in /usr/sbin/gdm) and changed the output redirection from /dev/null to /tmp/gdm.log.

However, that didn't work because in gdm we explicitly set the stdout/err to NULL for both the master and slave process.  So, in the attached patch you will see that I changed it to only close fds above 2 and inherit the stdin/out/err from the parent.  I think that is a reasonable thing to do in general but isn't really necessary for this patch.

Once I was able to see the dbus debug output it was showing that the socket was  disconnecting sometime around the time CloseSession was called.  But the is-disconnected state was never propagated to the rest of the library until later so the proxy calls didn't fail in a well defined way.

Then it occurred to me that we don't reenter the main loop at all while waiting for the session child process.  We do some selects, loop, and then waitpid.  This breaks the dbus client library.

Long term I think it makes sense to rework the slave code around a mainloop (ie. more object oriented, see bug #376010).  However, for now I think an appropriate fix is to just explicitly interate the main loop.  It seems to work.

This patch also explicitly says to not exit on bus disconnection.

It still seems like there is a bug somewhere causing the disconnect in the first place.  But I still think these changes are probably ok.

The other changes in this patch are:
* build fix for greeter
* change g_warning to gdm_error so they are logged
Comment 8 Brian Cameron 2007-01-29 03:12:06 UTC
William, thanks for looking into this.  

When you say that "we don't reenter the main loop at all while waiting for the session child process.".  I assume you are talking about the slave daemon process here since I note the ConsoleKit code is only called from daemon/slave.c.  

I worry about a patch that makes the slave iterate around a mainloop in the daemon/consolekit.c code because this code is configurable.  If you run configure with consolekit turned off, then this code doesn't get built at all.  I think we should avoid making GDM run in very different ways based on configuration choices.  If it is necessary to rework the slave code to make it work with D-Bus, then this really should be done in a more general way - not in the ConsoleKit specific code.  Your thoughts?

Also you say that you would like to better understand why D-Bus is causing the disconnect and that you think your patch is "probably ok".  This sort of language doesn't make me feel really confident this is the right patch.  :)

Perhaps it makes more sense to backout ConsoleKit support in GDM 2.18 or at least update configure to not turn on ConsoleKit support by default.  It doesn't seem ready.  It seems more "experimental" code that is "try at your own risk".  

There are other bugs (e.g. bug #134696) regarding the fact that GDM doesn't nicely allow people to access stdout/stderr.  I don't think the "#if 0" code in your patch is the right way to do this, though.

I'd say that if debug/Enable=true in the configuration file, that it would be okay to avoid closing the file descriptors - and allow debug stderr/stdout messages to go somewhere more useful for debugging.  This would be a better approach I think.
Comment 9 William Jon McCann 2007-01-31 17:45:58 UTC
Created attachment 81610 [details] [review]
patch

Well in the end it seems that the glib bindings just aren't up to this task.  I've reworked this to use the lower level API and everything works now.  This patch should be ready to commit.  Look OK?
Comment 10 Brian Cameron 2007-02-05 04:56:37 UTC
Looks good, please commit.
Comment 11 William Jon McCann 2007-02-05 05:15:43 UTC
Done.  Thanks.