Subject: 24.3; Emacs crashes as g_main_context_prepare() is called recursively

From: Akshay Shekher <[email-masked]>
Date: Fri, 5 Dec 2014 22:40:25 +0530

When i start emacs normally it crashes, it works fine in no-window-system
mode

[Output]
┌─[user@ares:~]
└─> emacs

** (emacs:21613): WARNING **: Couldn't connect to accessibility bus: Failed
to connect to socket /tmp/dbus-E81xRNlu9o: Connection refused
X protocol error: RenderBadPicture (invalid Picture parameter) on protocol
request 139
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:21613): GLib-WARNING **: g_main_context_prepare() called recursively
from within a source's check() or prepare() member.

(emacs:21613): GLib-WARNING **: g_main_context_check() called recursively
from within a source's check() or prepare() member.
Fatal error 6: Aborted
Backtrace:
emacs[0x4f74cb]
emacs[0x4dcf3e]
emacs[0x4f7513]
emacs[0x4b219b]
emacs[0x4b420c]
emacs[0x4b426d]
/usr/lib/x86_64-linux-gnu/libX11.so.6(_XError+0x12b)[0x7fac3cdf654b]
/usr/lib/x86_64-linux-gnu/libX11.so.6(+0x3b5e7)[0x7fac3cdf35e7]
/usr/lib/x86_64-linux-gnu/libX11.so.6(+0x3b695)[0x7fac3cdf3695]
/usr/lib/x86_64-linux-gnu/libX11.so.6(_XEventsQueued+0x55)[0x7fac3cdf3fc5]
/usr/lib/x86_64-linux-gnu/libX11.so.6(XFlush+0x1a)[0x7fac3cdd6b4a]
...
Aborted (core dumped)

[gdb output]

└─> gdb emacs
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from emacs...(no debugging symbols found)...done.
(gdb) bt full
No stack.
(gdb) run
Starting program: /usr/bin/emacs
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

** (emacs:21084): WARNING **: Couldn't connect to accessibility bus: Failed
to connect to socket /tmp/dbus-E81xRNlu9o: Connection refused
[New Thread 0x7fffe9720700 (LWP 21088)]
[New Thread 0x7fffe3df2700 (LWP 21089)]
X protocol error: RenderBadPicture (invalid Picture parameter) on protocol
request 139
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:21084): GLib-WARNING **: g_main_context_prepare() called recursively
from within a source's check() or prepare() member.

(emacs:21084): GLib-WARNING **: g_main_context_check() called recursively
from within a source's check() or prepare() member.
Fatal error 6: Aborted
Backtrace:
/usr/bin/emacs[0x4f74cb]
/usr/bin/emacs[0x4dcf3e]
/usr/bin/emacs[0x4f7513]
/usr/bin/emacs[0x4b219b]
/usr/bin/emacs[0x4b420c]
/usr/bin/emacs[0x4b426d]
/usr/lib/x86_64-linux-gnu/libX11.so.6(_XError+0x12b)[0x7ffff4e9054b]
/usr/lib/x86_64-linux-gnu/libX11.so.6(+0x3b5e7)[0x7ffff4e8d5e7]
/usr/lib/x86_64-linux-gnu/libX11.so.6(+0x3b695)[0x7ffff4e8d695]
/usr/lib/x86_64-linux-gnu/libX11.so.6(_XEventsQueued+0x55)[0x7ffff4e8dfc5]
/usr/lib/x86_64-linux-gnu/libX11.so.6(XFlush+0x1a)[0x7ffff4e70b4a]
...

Program received signal SIGABRT, Aborted.
0x00007ffff1d2e20b in raise (sig=6) at
../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37
37 ../nptl/sysdeps/unix/sysv/linux/pt-raise.c: No such file or directory.
(gdb) bt full
#0  0x00007ffff1d2e20b in raise (sig=6) at
../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37
        resultvar = 0
        pid = <optimized out>
#1  0x00000000004dcf66 in ?? ()
No symbol table info available.
#2  0x00000000004f7513 in ?? ()
No symbol table info available.
#3  0x00000000004b219b in ?? ()
No symbol table info available.
#4  0x00000000004b420c in ?? ()
No symbol table info available.
#5  0x00000000004b426d in ?? ()
No symbol table info available.
#6  0x00007ffff4e9054b in _XError () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#7  0x00007ffff4e8d5e7 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#8  0x00007ffff4e8d695 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#9  0x00007ffff4e8dfc5 in _XEventsQueued () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#10 0x00007ffff4e70b4a in XFlush () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#11 0x00007ffff4eac0c6 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#12 0x00007ffff4e9a8d2 in XDestroyIC () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#13 0x00000000004c4a7c in ?? ()
No symbol table info available.
#14 0x00000000004bba46 in ?? ()
No symbol table info available.
#15 0x00000000004bbd0b in ?? ()
No symbol table info available.
#16 0x0000000000424727 in ?? ()
No symbol table info available.
#17 0x00000000004b2210 in ?? ()
No symbol table info available.
#18 0x00000000004b420c in ?? ()
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
#19 0x00000000004b426d in ?? ()
No symbol table info available.
#20 0x00007ffff4e9054b in _XError () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#21 0x00007ffff4e8d5e7 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#22 0x00007ffff4e8d695 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#23 0x00007ffff4e8dfc5 in _XEventsQueued () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#24 0x00007ffff4e8012d in XPending () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
No symbol table info available.
#25 0x00007ffff663dc1b in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
No symbol table info available.
#26 0x00007ffff55f368d in g_main_context_prepare () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#27 0x00007ffff55f3f03 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#28 0x00007ffff55f4097 in g_main_context_pending () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#29 0x00007ffff6a43d8d in gtk_events_pending () from
/usr/lib/x86_64-linux-gnu/libgtk-3.so.0
No symbol table info available.
#30 0x00000000004b234b in ?? ()
No symbol table info available.
#31 0x00000000004e4321 in ?? ()
No symbol table info available.
#32 0x00000000004e3d05 in ?? ()
No symbol table info available.
#33 0x000000000058704d in ?? ()
No symbol table info available.
#34 0x000000000054fa0f in ?? ()
No symbol table info available.
#35 0x000000000054fd1b in ?? ()
No symbol table info available.
#36 0x00000000005511cf in ?? ()
No symbol table info available.
#37 0x000000000054f5a3 in ?? ()
No symbol table info available.
#38 0x000000000054f715 in ?? ()
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
#39 0x0000000000551f22 in ?? ()
No symbol table info available.
#40 0x000000000054f5d9 in ?? ()
No symbol table info available.
#41 0x000000000054f715 in ?? ()
No symbol table info available.
#42 0x000000000054fa9c in ?? ()
No symbol table info available.
#43 0x000000000054ee2d in ?? ()
No symbol table info available.
#44 0x000000000054f1f2 in ?? ()
No symbol table info available.
#45 0x000000000054f715 in ?? ()
No symbol table info available.
#46 0x000000000054f5d9 in ?? ()
No symbol table info available.
#47 0x000000000054f715 in ?? ()
No symbol table info available.
#48 0x00000000005521c9 in ?? ()
No symbol table info available.
#49 0x000000000054f5d9 in ?? ()
No symbol table info available.
#50 0x000000000054f715 in ?? ()
No symbol table info available.
#51 0x000000000054fa9c in ?? ()
No symbol table info available.
#52 0x000000000054fd1b in ?? ()
No symbol table info available.
#53 0x000000000058494b in ?? ()
No symbol table info available.
#54 0x000000000054fa0f in ?? ()
No symbol table info available.
#55 0x000000000054fd1b in ?? ()
No symbol table info available.
#56 0x000000000058494b in ?? ()
No symbol table info available.
#57 0x000000000054fa0f in ?? ()
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
#58 0x000000000054fd1b in ?? ()
No symbol table info available.
#59 0x000000000058494b in ?? ()
No symbol table info available.
#60 0x000000000054fa0f in ?? ()
No symbol table info available.
#61 0x000000000054fd1b in ?? ()
No symbol table info available.
#62 0x000000000058494b in ?? ()
No symbol table info available.
#63 0x000000000054fa0f in ?? ()
No symbol table info available.
#64 0x000000000054fd1b in ?? ()
No symbol table info available.
#65 0x000000000055005a in ?? ()
No symbol table info available.
#66 0x00000000005719dc in ?? ()
No symbol table info available.
#67 0x00000000005721fb in ?? ()
No symbol table info available.
#68 0x000000000054f391 in ?? ()
No symbol table info available.
#69 0x0000000000552511 in ?? ()
No symbol table info available.
#70 0x00000000005854f8 in ?? ()
No symbol table info available.
#71 0x000000000054fa0f in ?? ()
No symbol table info available.
#72 0x000000000054fd1b in ?? ()
No symbol table info available.
#73 0x000000000055005a in ?? ()
No symbol table info available.
#74 0x0000000000556b5a in ?? ()
No symbol table info available.
#75 0x000000000055975f in ?? ()
No symbol table info available.
#76 0x000000000054fe9d in ?? ()
No symbol table info available.
#77 0x000000000058494b in ?? ()
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
#78 0x000000000054fa0f in ?? ()
No symbol table info available.
#79 0x000000000054fd1b in ?? ()
No symbol table info available.
#80 0x000000000058494b in ?? ()
No symbol table info available.
#81 0x000000000054fa0f in ?? ()
No symbol table info available.
#82 0x000000000054fd1b in ?? ()
No symbol table info available.
#83 0x000000000058494b in ?? ()
No symbol table info available.
#84 0x000000000054fd1b in ?? ()
No symbol table info available.
#85 0x000000000058494b in ?? ()
No symbol table info available.
#86 0x000000000054ee2d in ?? ()
No symbol table info available.
#87 0x000000000054f1f2 in ?? ()
No symbol table info available.
#88 0x00000000005525fd in ?? ()
No symbol table info available.
#89 0x000000000054e3e3 in ?? ()
No symbol table info available.
#90 0x00000000004dd446 in ?? ()
No symbol table info available.
#91 0x000000000054e2be in ?? ()
No symbol table info available.
#92 0x00000000004e1bff in ?? ()
No symbol table info available.
#93 0x00000000004e1f14 in ?? ()
No symbol table info available.
#94 0x00000000004171d5 in ?? ()
No symbol table info available.
#95 0x00007ffff1979ec5 in __libc_start_main (main=0x4167c0, argc=1,
argv=0x7fffffffdf88, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>,
    stack_end=0x7fffffffdf78) at libc-start.c:287
        result = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0,
-1748833076626754881, 4291781, 140737488347008, 0, 0, 1748833075511784127,
1748811426720346815},
---Type <return> to continue, or q <return> to quit---
              mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x5d1510,
0x7fffffffdf88}, data = {prev = 0x0, cleanup = 0x0, canceltype = 6100240}}}
        not_first_call = <optimized out>
#96 0x0000000000417cee in ?? ()
No symbol table info available.
(gdb) backtrace
#0  0x00007ffff1d2e20b in raise (sig=6) at
../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37
#1  0x00000000004dcf66 in ?? ()
#2  0x00000000004f7513 in ?? ()
#3  0x00000000004b219b in ?? ()
#4  0x00000000004b420c in ?? ()
#5  0x00000000004b426d in ?? ()
#6  0x00007ffff4e9054b in _XError () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
#7  0x00007ffff4e8d5e7 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#8  0x00007ffff4e8d695 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#9  0x00007ffff4e8dfc5 in _XEventsQueued () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
#10 0x00007ffff4e70b4a in XFlush () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
#11 0x00007ffff4eac0c6 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#12 0x00007ffff4e9a8d2 in XDestroyIC () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
#13 0x00000000004c4a7c in ?? ()
#14 0x00000000004bba46 in ?? ()
#15 0x00000000004bbd0b in ?? ()
#16 0x0000000000424727 in ?? ()
#17 0x00000000004b2210 in ?? ()
#18 0x00000000004b420c in ?? ()
#19 0x00000000004b426d in ?? ()
#20 0x00007ffff4e9054b in _XError () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
#21 0x00007ffff4e8d5e7 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#22 0x00007ffff4e8d695 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#23 0x00007ffff4e8dfc5 in _XEventsQueued () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
#24 0x00007ffff4e8012d in XPending () from
/usr/lib/x86_64-linux-gnu/libX11.so.6
#25 0x00007ffff663dc1b in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#26 0x00007ffff55f368d in g_main_context_prepare () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#27 0x00007ffff55f3f03 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#28 0x00007ffff55f4097 in g_main_context_pending () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#29 0x00007ffff6a43d8d in gtk_events_pending () from
/usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#30 0x00000000004b234b in ?? ()
#31 0x00000000004e4321 in ?? ()
#32 0x00000000004e3d05 in ?? ()
#33 0x000000000058704d in ?? ()
#34 0x000000000054fa0f in ?? ()
#35 0x000000000054fd1b in ?? ()
#36 0x00000000005511cf in ?? ()
#37 0x000000000054f5a3 in ?? ()
#38 0x000000000054f715 in ?? ()
---Type <return> to continue, or q <return> to quit---
#39 0x0000000000551f22 in ?? ()
#40 0x000000000054f5d9 in ?? ()
#41 0x000000000054f715 in ?? ()
#42 0x000000000054fa9c in ?? ()
#43 0x000000000054ee2d in ?? ()
#44 0x000000000054f1f2 in ?? ()
#45 0x000000000054f715 in ?? ()
#46 0x000000000054f5d9 in ?? ()
#47 0x000000000054f715 in ?? ()
#48 0x00000000005521c9 in ?? ()
#49 0x000000000054f5d9 in ?? ()
#50 0x000000000054f715 in ?? ()
#51 0x000000000054fa9c in ?? ()
#52 0x000000000054fd1b in ?? ()
#53 0x000000000058494b in ?? ()
#54 0x000000000054fa0f in ?? ()
#55 0x000000000054fd1b in ?? ()
#56 0x000000000058494b in ?? ()
#57 0x000000000054fa0f in ?? ()
#58 0x000000000054fd1b in ?? ()
#59 0x000000000058494b in ?? ()
#60 0x000000000054fa0f in ?? ()
#61 0x000000000054fd1b in ?? ()
#62 0x000000000058494b in ?? ()
#63 0x000000000054fa0f in ?? ()
#64 0x000000000054fd1b in ?? ()
#65 0x000000000055005a in ?? ()
#66 0x00000000005719dc in ?? ()
#67 0x00000000005721fb in ?? ()
#68 0x000000000054f391 in ?? ()
#69 0x0000000000552511 in ?? ()
#70 0x00000000005854f8 in ?? ()
#71 0x000000000054fa0f in ?? ()
#72 0x000000000054fd1b in ?? ()
#73 0x000000000055005a in ?? ()
#74 0x0000000000556b5a in ?? ()
#75 0x000000000055975f in ?? ()
#76 0x000000000054fe9d in ?? ()
#77 0x000000000058494b in ?? ()
---Type <return> to continue, or q <return> to quit---
#78 0x000000000054fa0f in ?? ()
#79 0x000000000054fd1b in ?? ()
#80 0x000000000058494b in ?? ()
#81 0x000000000054fa0f in ?? ()
#82 0x000000000054fd1b in ?? ()
#83 0x000000000058494b in ?? ()
#84 0x000000000054fd1b in ?? ()
#85 0x000000000058494b in ?? ()
#86 0x000000000054ee2d in ?? ()
#87 0x000000000054f1f2 in ?? ()
#88 0x00000000005525fd in ?? ()
#89 0x000000000054e3e3 in ?? ()
#90 0x00000000004dd446 in ?? ()
#91 0x000000000054e2be in ?? ()
#92 0x00000000004e1bff in ?? ()
#93 0x00000000004e1f14 in ?? ()
#94 0x00000000004171d5 in ?? ()
#95 0x00007ffff1979ec5 in __libc_start_main (main=0x4167c0, argc=1,
argv=0x7fffffffdf88, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>,
    stack_end=0x7fffffffdf78) at libc-start.c:287
#96 0x0000000000417cee in ?? ()
(gdb)

In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7)
 of 2014-03-07 on lamiak, modified by Debian
System Description: elementary OS Freya

Configured using:
 `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var/lib' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-lisp:/usr/share/emacs/site-lisp'
 '--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes'
 '--with-x-toolkit=gtk3' '--with-toolkit-scroll-bars'
 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
 --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall'
 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro'
 'CPPFLAGS=-D_FORTIFY_SOURCE=2''