unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Colascione <dancol@dancol.org>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: "Peter Münster" <pmlists@free.fr>, emacs-devel@gnu.org
Subject: Re: trunk r116499: Improve dbus error handling; detect bus failure
Date: Mon, 24 Feb 2014 05:48:45 -0800	[thread overview]
Message-ID: <530B4DBD.1090901@dancol.org> (raw)
In-Reply-To: <87vbw4ejpb.fsf@gmx.de>

On 02/24/2014 05:14 AM, Michael Albinus wrote:
> Michael Albinus <michael.albinus@gmx.de> writes:
>
>> --8<---------------cut here---------------start------------->8---
>> Debugger entered--Lisp error: (dbus-error "call timed out")
>>    signal(dbus-error ("call timed out"))
>>    byte-code(...)
>>    dbus-list-names(:session)
>>    dbus-register-method(:session "a.b" "/a/b" "a.b" "c" ignore)
>>    eval((dbus-register-method :session "a.b" "/a/b" "a.b" "c" (quote ignore)) nil)
>>    eval-last-sexp-1(nil)
>>    eval-last-sexp(nil)
>>    call-interactively(eval-last-sexp nil nil)
>>    command-execute(eval-last-sexp)
>> --8<---------------cut here---------------end--------------->8---
>>
>> *Messages* contains the traces.
>
> PS: The *Messages* buffer shows, that the result for dbus-list-names(:session)
> has arrived. Maybe your new mechanism has kicked off the result from
> `dbus-return-values-table', or it could not be read due to the changed layout.

Thanks for coming up with that. I can only repro this problem with 
dbus-debug turned on, but I think this issue is what Peter's been 
hitting too. It's actually a core Emacs event loop bug that we never 
noticed before due to checking read-event's return value and breaking 
the loop early if it ever returns a dbus event.

The problem is this code from read_char in keyboard.c:

   if (NILP (c))
     {
       c = read_decoded_event_from_main_queue (end_time, local_getcjmp,
                                               prev_event, used_mouse_menu);
       if (end_time && timespec_cmp (*end_time, current_timespec ()) <= 0)
         goto exit;
       if (EQ (c, make_number (-2)))
         {
	  /* This is going to exit from read_char
	     so we had better get rid of this frame's stuff.  */
	  UNGCPRO;
           return c;
         }
   }

c here is our dbus event. We managed to successfully read the event, but 
by the time we returned from read_decoded_event_from_main_queue, we've 
exceeded the allowed timeout, so we jump directly to exit, completely 
bypassing the part of read_char that sends the event to 
special_event_map. As a result, we drop the event on the floor and never 
process it. The race is small, but because we're using very small 
timeout values, we hit it more than some other code might.

I apparently have a fast enough machine that I never hit this problem 
during testing. :-)

Can you try this patch?

=== modified file 'src/keyboard.c'
--- src/keyboard.c	2014-02-08 04:02:16 +0000
+++ src/keyboard.c	2014-02-24 13:47:18 +0000
@@ -2891,8 +2891,12 @@
      {
        c = read_decoded_event_from_main_queue (end_time, local_getcjmp,
                                                prev_event, 
used_mouse_menu);
-      if (end_time && timespec_cmp (*end_time, current_timespec ()) <= 0)
-        goto exit;
+      if (NILP(c) && end_time &&
+          timespec_cmp (*end_time, current_timespec ()) <= 0)
+        {
+          goto exit;
+        }
+
        if (EQ (c, make_number (-2)))
          {
  	  /* This is going to exit from read_char




  reply	other threads:[~2014-02-24 13:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1WGhnF-0006bq-Ma@vcs.savannah.gnu.org>
2014-02-24  8:18 ` trunk r116499: Improve dbus error handling; detect bus failure Michael Albinus
2014-02-24  8:24   ` Daniel Colascione
2014-02-24  8:54     ` Michael Albinus
2014-02-24 11:45       ` Peter Münster
2014-02-24 12:50         ` Daniel Colascione
2014-02-24 12:59           ` Daniel Colascione
2014-02-24 13:09           ` Michael Albinus
2014-02-24 13:14             ` Michael Albinus
2014-02-24 13:48               ` Daniel Colascione [this message]
2014-02-24 14:25                 ` Michael Albinus
2014-02-24 18:52                   ` Peter Münster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=530B4DBD.1090901@dancol.org \
    --to=dancol@dancol.org \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=pmlists@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).