Bug 1277840

Summary: after emacs crash, XIfEvent stuck in busy loop
Product: [Fedora] Fedora Reporter: Stephan Bergmann <sbergman>
Component: libX11Assignee: Adam Jackson <ajax>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 23CC: ajax, sandmann
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-20 15:21:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Stephan Bergmann 2015-11-04 08:36:32 UTC
A /usr/bin/emacs process happened to crash for me, and then got stuck with 100% CPU load.  Looking with GDB, what happened is that the main thread is stuck in a busy loop in XIfEvent repeatedly calling _XReadEvents, which keeps returning early with

> if(dpy->flags & XlibDisplayIOError)
>   return;

(where dpy->flags == XlibDisplayIOError, aka 1).  It looks like maybe XIfEvent should also break out of its loop under that error condition?

Package versions:
libX11-1.6.3-2.fc23.x86_64
emacs-24.5-6.fc23.x86_64

Full stack:

> #0  0x00007fa5c8b8bd40 in _XReadEvents (dpy=dpy@entry=0x13d8c00) at /usr/src/debug/libX11-1.6.3/src/xcb_io.c:379
> #1  0x00007fa5c8b737f9 in XIfEvent (dpy=0x13d8c00, event=event@entry=0x7ffc29ce5de0, predicate=predicate@entry=0x7fa5c8bbb830 <_CheckCMEvent>, arg=arg@entry=0x2b70000 "@a\350ȥ\177") at /usr/src/debug/libX11-1.6.3/src/IfEvent.c:68
> #2  0x00007fa5c8bbbfc3 in _XimXRead (im=0x2b70000, recv_buf=0x7ffc29ce67d0 "", buf_len=2048, ret_len=0x7ffc29ce5f14) at /usr/src/debug/libX11-1.6.3/modules/im/ximcp/imTrX.c:476
> #3  0x00007fa5c8bbcbf7 in _XimReadData (im=im@entry=0x2b70000, len=len@entry=0x7ffc29ce5f76, buf=buf@entry=0x7ffc29ce67d0 "", buf_size=buf_size@entry=2048) at /usr/src/debug/libX11-1.6.3/modules/im/ximcp/imTransR.c:165
> #4  0x00007fa5c8bbced1 in _XimRead (im=im@entry=0x2b70000, len=len@entry=0x7ffc29ce5fce, buf=buf@entry=0x7ffc29ce67d0 "", buf_size=buf_size@entry=2048, predicate=predicate@entry=0x7fa5c8baa9a0 <_XimDestroyICCheck>, arg=arg@entry=0x13e7260 "\340`\350ȥ\177") at /usr/src/debug/libX11-1.6.3/modules/im/ximcp/imTransR.c:235
> #5  0x00007fa5c8baaeb0 in _XimProtoDestroyIC (xic=0x13e7260) at /usr/src/debug/libX11-1.6.3/modules/im/ximcp/imDefIc.c:914
> #6  0x00007fa5c8b98df2 in XDestroyIC (ic=0x13e7260) at /usr/src/debug/libX11-1.6.3/src/xlibi18n/ICWrap.c:265
> #7  0x00000000004cffaf in free_frame_xic (f=f@entry=0x1175248) at /usr/src/debug/emacs-24.5/src/xfns.c:2087
> #8  0x00000000004c8a7c in x_free_frame_resources (f=<optimized out>) at /usr/src/debug/emacs-24.5/src/xterm.c:9275
> #9  0x00000000004c8f6b in x_destroy_window (f=<optimized out>) at /usr/src/debug/emacs-24.5/src/xterm.c:9383
> #10 0x000000000042614d in delete_frame (frame=<optimized out>, force=<optimized out>) at /usr/src/debug/emacs-24.5/src/frame.c:1387
> #11 0x00000000004bf3f0 in x_connection_closed (dpy=<optimized out>, error_message=<optimized out>) at /usr/src/debug/emacs-24.5/src/xterm.c:7635
> #12 0x00000000004bf4ef in x_io_error_quitter (display=<optimized out>) at /usr/src/debug/emacs-24.5/src/xterm.c:7762
> #13 0x00007fa5c8b8e43e in _XIOError (dpy=dpy@entry=0x13d8c00) at /usr/src/debug/libX11-1.6.3/src/XlibInt.c:1464
> #14 0x00007fa5c8b8c49a in _XReply (dpy=dpy@entry=0x13d8c00, rep=rep@entry=0x7ffc29ce72e0, extra=extra@entry=0, discard=discard@entry=1) at /usr/src/debug/libX11-1.6.3/src/xcb_io.c:708
> #15 0x00007fa5c8b87bdd in XSync (dpy=0x13d8c00, discard=0) at /usr/src/debug/libX11-1.6.3/src/Sync.c:44
> #16 0x00007fa5ca9d4981 in gdk_window_process_all_updates () at /usr/src/debug/gtk+-3.18.2/gdk/gdkwindow.c:3785
> #17 0x00007fa5ca9d4981 in gdk_window_process_all_updates () at /usr/src/debug/gtk+-3.18.2/gdk/gdkwindow.c:3851
> #18 0x00000000004c411b in x_catch_errors (dpy=<optimized out>) at /usr/src/debug/emacs-24.5/src/xterm.c:7490
> #19 0x00000000004d44c6 in x_get_foreign_selection (selection_symbol=<optimized out>, target_type=12640194, time_stamp=12331890, frame=frame@entry=18305613) at /usr/src/debug/emacs-24.5/src/xselect.c:1210
> #20 0x00000000004d468c in x_clipboard_manager_save (frame=frame@entry=18305613) at /usr/src/debug/emacs-24.5/src/xselect.c:2171
> #21 0x000000000055feab in internal_condition_case_1 (bfun=bfun@entry=0x4d4610 <x_clipboard_manager_save>, arg=arg@entry=18305613, handlers=<optimized out>, hfun=hfun@entry=0x4d2fd0 <x_clipboard_manager_error_2>) at /usr/src/debug/emacs-24.5/src/eval.c:1372
> #22 0x00000000004d5c8e in x_clipboard_manager_save_all () at /usr/src/debug/emacs-24.5/src/xselect.c:2256
> #23 0x00000000004ec16c in Fkill_emacs (arg=arg@entry=60) at /usr/src/debug/emacs-24.5/src/emacs.c:1945
> #24 0x00000000004ec27c in terminate_due_to_signal (sig=15, backtrace_limit=backtrace_limit@entry=40) at /usr/src/debug/emacs-24.5/src/emacs.c:358
> #25 0x000000000050519e in handle_fatal_signal (sig=<optimized out>) at /usr/src/debug/emacs-24.5/src/sysdep.c:1630
> #26 0x000000000050601d in deliver_process_signal (sig=15, handler=0x505190 <handle_fatal_signal>) at /usr/src/debug/emacs-24.5/src/sysdep.c:1570
> #27 0x00007fa5c554d9f0 in <signal handler called> () at /lib64/libpthread.so.0
> #28 0x00007fa5c554d8c9 in raise (sig=15) at /usr/src/debug/glibc-2.22/sysdeps/unix/sysv/linux/pt-raise.c:36
> #29 0x00007fa5c154ed30 in ffi_call_unix64 () at /usr/src/debug/libffi-3.1/src/x86/unix64.S:76
> #30 0x00007fa5c154e79b in ffi_call (cif=cif@entry=0x7ffc29ce7dc0, fn=<optimized out>, rvalue=0x7ffc29ce7d10, avalue=avalue@entry=0x7ffc29ce7cb0) at /usr/src/debug/libffi-3.1/src/x86/ffi64.c:525
> #31 0x00007fa5c95f74f5 in g_cclosure_marshal_generic_va (closure=0x29ab890, return_value=0x0, instance=0x146c150, args_list=<optimized out>, marshal_data=0x7fa5c9906520 <g_dbus_connection_real_closed>, n_params=2, param_types=0x29ab900) at /usr/src/debug/glib-2.46.1/gobject/gclosure.c:1600
> #32 0x00007fa5c95f69d4 in _g_closure_invoke_va (closure=closure@entry=0x29ab890, return_value=return_value@entry=0x0, instance=instance@entry=0x146c150, args=args@entry=0x7ffc29ce8060, n_params=<optimized out>, param_types=0x29ab900) at /usr/src/debug/glib-2.46.1/gobject/gclosure.c:864
> #33 0x00007fa5c96112bd in g_signal_emit_valist (instance=0x146c150, signal_id=<optimized out>, detail=0, var_args=var_args@entry=0x7ffc29ce8060) at /usr/src/debug/glib-2.46.1/gobject/gsignal.c:3292
> #34 0x00007fa5c96118ff in g_signal_emit (instance=<optimized out>, signal_id=<optimized out>, detail=detail@entry=0) at /usr/src/debug/glib-2.46.1/gobject/gsignal.c:3439
> #35 0x00007fa5c9905105 in emit_closed_in_idle (user_data=0x7fa5a800a030) at /usr/src/debug/glib-2.46.1/gio/gdbusconnection.c:1357
> #36 0x00007fa5c92f7e3a in g_main_context_dispatch (context=0x13d65f0) at /usr/src/debug/glib-2.46.1/glib/gmain.c:3154
> #37 0x00007fa5c92f7e3a in g_main_context_dispatch (context=context@entry=0x13d65f0) at /usr/src/debug/glib-2.46.1/glib/gmain.c:3769
> #38 0x00000000005dc0d0 in xg_select (fds_lim=14, rfds=rfds@entry=0x7ffc29ce88b0, wfds=wfds@entry=0x7ffc29ce8930, efds=efds@entry=0x0, timeout=timeout@entry=0x7ffc29ce8890, sigmask=sigmask@entry=0x0) at /usr/src/debug/emacs-24.5/src/xgselect.c:159
> #39 0x00000000005a26a9 in wait_reading_process_output (time_limit=time_limit@entry=45, nsecs=nsecs@entry=0, read_kbd=read_kbd@entry=-1, do_display=do_display@entry=true, wait_for_cell=12331890, wait_proc=wait_proc@entry=0x0, just_wait_proc=0) at /usr/src/debug/emacs-24.5/src/process.c:4606
> #40 0x0000000000422663 in sit_for (timeout=<optimized out>, reading=reading@entry=true, display_option=display_option@entry=1) at /usr/src/debug/emacs-24.5/src/dispnew.c:5867
> #41 0x00000000004f783c in read_char (commandflag=1, map=map@entry=51788854, prev_event=12331890, used_mouse_menu=used_mouse_menu@entry=0x7ffc29ce8edb, end_time=end_time@entry=0x0) at /usr/src/debug/emacs-24.5/src/keyboard.c:2810
> #42 0x00000000004f8a88 in read_key_sequence (keybuf=keybuf@entry=0x7ffc29ce8fe0, prompt=12331890, dont_downcase_last=dont_downcase_last@entry=false, can_return_switch_frame=can_return_switch_frame@entry=true, fix_current_buffer=fix_current_buffer@entry=true, prevent_redisplay=prevent_redisplay@entry=false, bufsize=30) at /usr/src/debug/emacs-24.5/src/keyboard.c:9089
> #43 0x00000000004fa88e in command_loop_1 () at /usr/src/debug/emacs-24.5/src/keyboard.c:1453
> #44 0x000000000055fd87 in internal_condition_case (bfun=bfun@entry=0x4fa670 <command_loop_1>, handlers=<optimized out>, hfun=hfun@entry=0x4f11c0 <cmd_error>) at /usr/src/debug/emacs-24.5/src/eval.c:1348
> #45 0x00000000004ec642 in command_loop_2 (ignore=ignore@entry=12331890) at /usr/src/debug/emacs-24.5/src/keyboard.c:1178
> #46 0x000000000055fc6b in internal_catch (tag=12379170, func=func@entry=0x4ec620 <command_loop_2>, arg=12331890) at /usr/src/debug/emacs-24.5/src/eval.c:1112
> #47 0x00000000004f0d83 in recursive_edit_1 () at /usr/src/debug/emacs-24.5/src/keyboard.c:1157
> #48 0x00000000004f0d83 in recursive_edit_1 () at /usr/src/debug/emacs-24.5/src/keyboard.c:778
> #49 0x00000000004f10d8 in Frecursive_edit () at /usr/src/debug/emacs-24.5/src/keyboard.c:849
> #50 0x0000000000418587 in main (argc=<optimized out>, argv=0x7ffc29ce9348) at /usr/src/debug/emacs-24.5/src/emacs.c:1642

Comment 1 Fedora End Of Life 2016-11-24 13:03:40 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 2 Fedora End Of Life 2016-12-20 15:21:05 UTC
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.