unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* GTK stack-busting loop
@ 2010-10-31  4:00 Chong Yidong
  2010-11-01  1:28 ` Stefan Monnier
  2010-11-01 11:43 ` Jan Djärv
  0 siblings, 2 replies; 4+ messages in thread
From: Chong Yidong @ 2010-10-31  4:00 UTC (permalink / raw)
  To: emacs-devel

On the trunk, with GTK, the following recipe causes an infloop:

1. emacs -Q -nw -f server-start
2. emacsclient -c
3. In another terminal, run `xkill' and click on the GTK toolbar

The backtrace is at the end of this message.  It can be obtained by
attaching to the looping Emacs process in another gdb session.
Eventually, the loop overflows the stack.

This bug does not occur on the emacs-23 branch, nor if you click `xkill'
on other parts of the graphical frame.  In those cases, Emacs aborts as
it now ought to.

The infloop arises when, during the UNBLOCK_INPUT at the end of
XTread_socket, Emacs checks for and processes more incoming input, via
read_avail_input.  Somehow, with the malfunctioning GTK code, this leads
to another XTread_socket call, etc.  I am not sure why the bug does not
manifest itself on the branch.  Anyone know?  (Jan?)

More generally, the possibility of such an infloop seems to indicate
that it makes sense not to use the normal UNBLOCK_INPUT at the end of
XTread_socket, but instead do this:

*** src/xterm.c	2010-10-25 16:04:54 +0000
--- src/xterm.c	2010-10-31 03:51:26 +0000
***************
*** 7056,7062 ****
      }
  
    --handling_signal;
!   UNBLOCK_INPUT;
  
    return count;
  }
--- 7056,7062 ----
      }
  
    --handling_signal;
!   --interrupt_input_blocked;
  
    return count;
  }

Any thoughts?  (Stefan?)

Here's the backtrace:

#0  0x00007f3a0e9838c0 in __write_nocancel () from /lib/libpthread.so.0
#1  0x00007f3a0ebdac8c in g_log_default_handler () from /lib/libglib-2.0.so.0
#2  0x00007f3a0ebdafb9 in g_logv () from /lib/libglib-2.0.so.0
#3  0x00007f3a0ebdb3d3 in g_log () from /lib/libglib-2.0.so.0
#4  0x00007f3a0ebd3a84 in g_main_context_check () from /lib/libglib-2.0.so.0
#5  0x00007f3a0ebd44c3 in ?? () from /lib/libglib-2.0.so.0
#6  0x00007f3a0ebd4a14 in g_main_context_pending () from /lib/libglib-2.0.so.0
#7  0x00007f3a111e3ab9 in gtk_events_pending ()
   from /usr/lib/libgtk-x11-2.0.so.0
#8  0x00000000004f6dc5 in XTread_socket (terminal=0x10a2e10, expected=1,
    hold_quit=0x7fff184c7fc0) at xterm.c:7009
#9  0x0000000000546059 in read_avail_input (expected=1) at keyboard.c:6969
#10 0x00000000005469e2 in handle_async_input () at keyboard.c:7292
#11 0x0000000000546af1 in reinvoke_input_signal () at keyboard.c:7348
#12 0x00000000004f6e94 in XTread_socket (terminal=0x10a2e10, expected=1,
    hold_quit=0x7fff184c8200) at xterm.c:7059
#13 0x0000000000546059 in read_avail_input (expected=1) at keyboard.c:6969
#14 0x00000000005469e2 in handle_async_input () at keyboard.c:7292
#15 0x0000000000546af1 in reinvoke_input_signal () at keyboard.c:7348
#16 0x00000000004f6e94 in XTread_socket (terminal=0x10a2e10, expected=1,
    hold_quit=0x7fff184c8440) at xterm.c:7059



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GTK stack-busting loop
  2010-10-31  4:00 GTK stack-busting loop Chong Yidong
@ 2010-11-01  1:28 ` Stefan Monnier
  2010-11-01 11:43 ` Jan Djärv
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2010-11-01  1:28 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

> *** src/xterm.c	2010-10-25 16:04:54 +0000
> --- src/xterm.c	2010-10-31 03:51:26 +0000
> ***************
> *** 7056,7062 ****
>       }
  
>     --handling_signal;
> !   UNBLOCK_INPUT;
  
>     return count;
>   }
> --- 7056,7062 ----
>       }
  
>     --handling_signal;
> !   --interrupt_input_blocked;
  
>     return count;
>   }

> Any thoughts?  (Stefan?)

That doesn't sound very good.
There's nothing wrong (fundamentally) with the UNBLOCK_INPUT causing
another call to XTread_socket: after all, we've basically finished the
first call when we get to UNBLOCK_INPUT, so there's no "nested
interrupt" problem, AFAICT.  After all, we're just coming out of
a "while (gtk_events_pending ())", so the case where we get "called
recursively" should be very rare.

I.e. I think this "problem" can only happen in bogus cases such as with
Gtk's bug.


        Stefan



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GTK stack-busting loop
  2010-10-31  4:00 GTK stack-busting loop Chong Yidong
  2010-11-01  1:28 ` Stefan Monnier
@ 2010-11-01 11:43 ` Jan Djärv
  2010-11-01 16:03   ` Chong Yidong
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Djärv @ 2010-11-01 11:43 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

2010-10-31 05:00, Chong Yidong skrev:
> On the trunk, with GTK, the following recipe causes an infloop:
>
> 1. emacs -Q -nw -f server-start
> 2. emacsclient -c
> 3. In another terminal, run `xkill' and click on the GTK toolbar
>
> The backtrace is at the end of this message.  It can be obtained by
> attaching to the looping Emacs process in another gdb session.
> Eventually, the loop overflows the stack.
>
> This bug does not occur on the emacs-23 branch, nor if you click `xkill'
> on other parts of the graphical frame.  In those cases, Emacs aborts as
> it now ought to.
>

I get the same behaviour in Emacs-23 and trunk, i.e.:
Connection lost to X server `:0.0'
When compiled with GTK, Emacs cannot recover from X disconnects.
This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715
For details, see etc/PROBLEMS.

(emacs:8582): GLib-WARNING **: g_main_context_prepare() called recursively 
from within a source's check() or prepare() member.

(emacs:8582): GLib-WARNING **: g_main_context_check() called recursively from 
within a source's check() or prepare() member.
Fatal error (6)Avbruten (SIGABRT)

	Jan D.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GTK stack-busting loop
  2010-11-01 11:43 ` Jan Djärv
@ 2010-11-01 16:03   ` Chong Yidong
  0 siblings, 0 replies; 4+ messages in thread
From: Chong Yidong @ 2010-11-01 16:03 UTC (permalink / raw)
  To: Jan Djärv; +Cc: emacs-devel

Jan Djärv <jan.h.d@swipnet.se> writes:

> I get the same behaviour in Emacs-23 and trunk, i.e.:
> Connection lost to X server `:0.0'
> When compiled with GTK, Emacs cannot recover from X disconnects.
> This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715
> For details, see etc/PROBLEMS.

Hmm, now I can't reproduce it either.  Oh well, sorry for the noise.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-01 16:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-31  4:00 GTK stack-busting loop Chong Yidong
2010-11-01  1:28 ` Stefan Monnier
2010-11-01 11:43 ` Jan Djärv
2010-11-01 16:03   ` Chong Yidong

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).