Subject: bug#6975: Emacs spinning in glib

From: Ken Raeburn <[email-masked]>
Date: Mon, 30 Aug 2010 23:30:13 -0400

I use emacsclient fairly heavily with Emacs 23.2 at work; mostly for getting additional windows on the local display, but occasionally with a remote display as well when I log into my work machine from home.  I tried to do the latter today, and a blank window popped up, but then Emacs was spinning and not responding.

strace shows it looping over:

write(2, "\n(emacs:29550): GLib-WARNING **: g_main_context_check() called recursively from within a source's check() or prepare() member.\n"..., 127) = 127
select(27, [4 6 7 11 13 14 15 17 19 22 23 25], NULL, NULL, {27, 232294}) = 1 (in [7], left {27, 232289})
write(2, "\n(emacs:29550): GLib-WARNING **: g_main_context_prepare() called recursively from within a source's check() or prepare() member.\n"..., 129) = 129
poll([{fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN|POLLPRI}, {fd=13, events=POLLIN|POLLPRI}, {fd=14, events=POLLIN|POLLPRI}, {fd=15, events=POLLIN|POLLPRI}, {fd=25, events=POLLIN}], 7, 0) = 1 ([{fd=7, revents=POLLIN}])
write(2, "\n(emacs:29550): GLib-WARNING **: g_main_context_check() called recursively from within a source's check() or prepare() member.\n"..., 127) = 127
write(2, "\n(emacs:29550): GLib-WARNING **: g_main_context_prepare() called recursively from within a source's check() or prepare() member.\n"..., 129) = 129
poll([{fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11, events=POLLIN|POLLPRI}, {fd=13, events=POLLIN|POLLPRI}, {fd=14, events=POLLIN|POLLPRI}, {fd=15, events=POLLIN|POLLPRI}, {fd=25, events=POLLIN}], 7, 0) = 1 ([{fd=7, revents=POLLIN}])
write(2, "\n(emacs:29550): GLib-WARNING **: g_main_context_check() called recursively from within a source's check() or prepare() member.\n"..., 127) = 127

I attached it under gdb and got this trace:

(gdb) bt
#0  0x00007fbb705c81a0 in _int_malloc () from /lib/libc.so.6
#1  0x00007fbb705c9ad8 in malloc () from /lib/libc.so.6
#2  0x00007fbb70570d30 in __gconv_open () from /lib/libc.so.6
#3  0x00007fbb705706be in iconv_open () from /lib/libc.so.6
#4  0x00007fbb72bf2ef9 in ?? () from /usr/lib/libglib-2.0.so.0
#5  0x00007fbb72bf2f42 in g_iconv_open () from /usr/lib/libglib-2.0.so.0
#6  0x00007fbb72bf34db in ?? () from /usr/lib/libglib-2.0.so.0
#7  0x00007fbb72bf392b in g_convert () from /usr/lib/libglib-2.0.so.0
#8  0x00007fbb72bf3e4d in g_convert_with_fallback () from /usr/lib/libglib-2.0.so.0
#9  0x00007fbb72c12816 in ?? () from /usr/lib/libglib-2.0.so.0
#10 0x00007fbb72c12edd in g_log_default_handler () from /usr/lib/libglib-2.0.so.0
#11 0x00007fbb72c13191 in g_logv () from /usr/lib/libglib-2.0.so.0
#12 0x00007fbb72c134f3 in g_log () from /usr/lib/libglib-2.0.so.0
#13 0x00007fbb72c0c933 in g_main_context_prepare () from /usr/lib/libglib-2.0.so.0
#14 0x00007fbb72c0cc7a in ?? () from /usr/lib/libglib-2.0.so.0
#15 0x00007fbb72c0d240 in g_main_context_pending () from /usr/lib/libglib-2.0.so.0
#16 0x00000000004d09a5 in xg_select (max_fds=26, rfds=0x7ffff0f6b100, wfds=0x0, efds=0x0, 
   timeout=0x7ffff0f6b290) at xgselect.c:134
#17 0x000000000059c56f in wait_reading_process_output (time_limit=0, microsecs=0, read_kbd=-1, 
   do_display=1, wait_for_cell=11624162, wait_proc=0x0, just_wait_proc=0) at process.c:4939
#18 0x00000000004f1d29 in read_char (commandflag=1, nmaps=2, maps=0x7ffff0f6b670, prev_event=11624162, 
   used_mouse_menu=0x7ffff0f6b78c, end_time=0x0) at keyboard.c:4135
#19 0x00000000004f3f17 in read_key_sequence (keybuf=0x7ffff0f6b800, bufsize=30, prompt=11624162, 
   dont_downcase_last=0, can_return_switch_frame=1, fix_current_buffer=1) at keyboard.c:9512
#20 0x00000000004f63a6 in command_loop_1 () at keyboard.c:1643
#21 0x000000000055971f in internal_condition_case (bfun=0x4f6190 <command_loop_1>, handlers=11691346, 
   hfun=0x4eff60 <cmd_error>) at eval.c:1490
#22 0x00000000004ef35e in command_loop_2 () at keyboard.c:1360
#23 0x0000000000559837 in internal_catch (tag=<value optimized out>, func=0x4ef340 <command_loop_2>, 
   arg=11624162) at eval.c:1226
#24 0x00000000004efd88 in command_loop () at keyboard.c:1339
#25 0x00000000004f017a in recursive_edit_1 () at keyboard.c:954
#26 0x00000000004f02f4 in Frecursive_edit () at keyboard.c:1016
#27 0x00000000004e2ecf in main (argc=2, argv=0x7ffff0f6c018) at emacs.c:1833
(gdb)

Unfortunately I don't have time to dig into it any more right now.