Subject: 27.0.50; emacsclient crashes on subsequent invocation when it cannot open a tty file

From: John Shahid <[email-masked]>
Date: Fri, 21 Sep 2018 11:03:09 -0400

This is a follow up to
http://lists.gnu.org/archive/html/emacs-devel/2018-09/msg00831.html.
The crash can be invoked by doing the following:

  emacs -q -nw --daemon
  sudo chown differentuser:differentgroup $(tty)
  emacsclient -t . # error because the tty cannot be opened
  emacsclient -t . # SIGSEGV is received and Emacs crashes

#0  __strcmp_sse2_unaligned ()
    at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:31
#1  0x000000000050ca04 in get_named_terminal (name=0x7fffffff2990 "/dev/pts/7")
    at terminal.c:255
#2  0x000000000050a808 in init_tty (name=0x7fffffff2990 "/dev/pts/7",
    terminal_type=0x7fffffff2970 "screen-256color", must_succeed=false)
    at term.c:3958
#3  0x00000000004281c9 in Fmake_terminal_frame (parms=XIL(0x1281253))
    at frame.c:1256
#4  0x000000000061863f in funcall_subr (subr=0x93b600 <Smake_terminal_frame>,
    numargs=1, args=0x7fffffff2b78) at eval.c:2929
#5  0x000000000061821c in Ffuncall (nargs=2, args=0x7fffffff2b70) at eval.c:2854
#6  0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x9b89c4),
    vector=XIL(0x9b89e5), maxdepth=make_number(12), args_template=make_number(256),
    nargs=1, args=0x7fffffff3090) at bytecode.c:632
#7  0x0000000000618cb7 in funcall_lambda (fun=XIL(0x9b8995), nargs=1,
    arg_vector=0x7fffffff3088) at eval.c:3055
#8  0x0000000000618260 in Ffuncall (nargs=2, args=0x7fffffff3080) at eval.c:2856
#9  0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x15ad434),
    vector=XIL(0xd7ddc5), maxdepth=make_number(3), args_template=make_number(257),
    nargs=1, args=0x7fffffff36a0) at bytecode.c:632
#10 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x1309245), nargs=1,
    arg_vector=0x7fffffff3698) at eval.c:3055
#11 0x0000000000618260 in Ffuncall (nargs=2, args=0x7fffffff3690) at eval.c:2856
#12 0x0000000000617166 in Fapply (nargs=2, args=0x7fffffff3690) at eval.c:2431
#13 0x0000000000618560 in funcall_subr (subr=0xc7c220 <Sapply>, numargs=2,
    args=0x7fffffff3690) at eval.c:2909
#14 0x000000000061821c in Ffuncall (nargs=3, args=0x7fffffff3688) at eval.c:2854
#15 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x122cea4),
    vector=XIL(0x13710e5), maxdepth=make_number(15),
    args_template=make_number(128), nargs=1, args=0x7fffffff3ba0) at bytecode.c:632
#16 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x1371165), nargs=1,
    arg_vector=0x7fffffff3ba0) at eval.c:3055
#17 0x0000000000618260 in Ffuncall (nargs=2, args=0x7fffffff3b98) at eval.c:2856
#18 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0xa47434),
    vector=XIL(0xa47455), maxdepth=make_number(13), args_template=make_number(256),
    nargs=1, args=0x7fffffff4130) at bytecode.c:632
#19 0x0000000000618cb7 in funcall_lambda (fun=XIL(0xa473f5), nargs=1,
    arg_vector=0x7fffffff4128) at eval.c:3055
#20 0x0000000000618260 in Ffuncall (nargs=2, args=0x7fffffff4120) at eval.c:2856
#21 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x102fef4),
    vector=XIL(0x14499e5), maxdepth=make_number(12),
    args_template=make_number(771), nargs=3, args=0x7fffffff4648) at bytecode.c:632
#22 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x1449ab5), nargs=3,
    arg_vector=0x7fffffff4630) at eval.c:3055
#23 0x0000000000618260 in Ffuncall (nargs=4, args=0x7fffffff4628) at eval.c:2856
#24 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x1032cc4),
    vector=XIL(0x14818e5), maxdepth=make_number(6), args_template=make_number(0),
    nargs=0, args=0x7fffffff4b58) at bytecode.c:632
#25 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x1481995), nargs=0,
    arg_vector=0x7fffffff4b58) at eval.c:3055
#26 0x0000000000618260 in Ffuncall (nargs=1, args=0x7fffffff4b50) at eval.c:2856
#27 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x1032db4),
    vector=XIL(0x144c945), maxdepth=make_number(14),
    args_template=make_number(1799), nargs=7, args=0x7fffffff50f8) at bytecode.c:632
#28 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x144ca85), nargs=7,
    arg_vector=0x7fffffff50c0) at eval.c:3055
#29 0x0000000000618260 in Ffuncall (nargs=8, args=0x7fffffff50b8) at eval.c:2856
#30 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x1032d04),
    vector=XIL(0x1481a15), maxdepth=make_number(8), args_template=make_number(0),
    nargs=0, args=0x7fffffff5590) at bytecode.c:632
#31 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x1481a85), nargs=0,
    arg_vector=0x7fffffff5590) at eval.c:3055
#32 0x0000000000618260 in Ffuncall (nargs=1, args=0x7fffffff5588) at eval.c:2856
#33 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x10323b4),
    vector=XIL(0x144a945), maxdepth=make_number(6), args_template=make_number(257),
    nargs=1, args=0x7fffffff5ac0) at bytecode.c:632
#34 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x144a975), nargs=1,
    arg_vector=0x7fffffff5ab8) at eval.c:3055
#35 0x0000000000618260 in Ffuncall (nargs=2, args=0x7fffffff5ab0) at eval.c:2856
#36 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x10323d4),
    vector=XIL(0x144ba05), maxdepth=make_number(35),
    args_template=make_number(514), nargs=2, args=0x7fffffff6328) at bytecode.c:632
#37 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x144bcb5), nargs=2,
    arg_vector=0x7fffffff6318) at eval.c:3055
#38 0x0000000000618260 in Ffuncall (nargs=3, args=0x7fffffff6310) at eval.c:2856
#39 0x0000000000617494 in Fapply (nargs=2, args=0x7fffffff63d0) at eval.c:2474
#40 0x0000000000617a46 in apply1 (fn=XIL(0x33ef00), arg=XIL(0x15c8903))
    at eval.c:2690
#41 0x00000000006755b5 in read_process_output_call (fun_and_args=XIL(0x15c88f3))
    at process.c:5807
#42 0x0000000000614990 in internal_condition_case_1 (
    bfun=0x675587 <read_process_output_call>, arg=XIL(0x15c88f3),
    handlers=XIL(0x5340), hfun=0x6755b7 <read_process_output_error_handler>)
    at eval.c:1395
#43 0x0000000000675e56 in read_and_dispose_of_process_output (p=0x1481700,
    chars=0x7fffffff6520 "id/Downloads/scala-2.8.1.final -env SDK=/home/jvshahid/Android/Sdk/ -env SHELL=/bin/zsh -env SHLVL=2 -env SSH_AUTH_SOCK=/home/jvshahid/.gnupg/S.gpg-agent.ssh -env TERM=screen-256color -env TMUX=/tmp/t"..., nbytes=1522,
    coding=0x10342b0) at process.c:6018
#44 0x0000000000675a77 in read_process_output (proc=XIL(0x1481705), channel=9)
    at process.c:5929
#45 0x0000000000674e0c in wait_reading_process_output (time_limit=4,
    nsecs=333410507, read_kbd=-1, do_display=true, wait_for_cell=XIL(0),
    wait_proc=0x0, just_wait_proc=0) at process.c:5626
#46 0x0000000000570b64 in kbd_buffer_get_event (kbp=0x7fffffff7a78,
    used_mouse_menu=0x0, end_time=0x7fffffff8050) at keyboard.c:3795
#47 0x000000000056ce0d in read_event_from_main_queue (end_time=0x7fffffff8050,
    local_getcjmp=0x7fffffff7e30, used_mouse_menu=0x0) at keyboard.c:2122
#48 0x000000000056d0ca in read_decoded_event_from_main_queue (
    end_time=0x7fffffff8050, local_getcjmp=0x7fffffff7e30, prev_event=XIL(0),
    used_mouse_menu=0x0) at keyboard.c:2185
#49 0x000000000056e808 in read_char (commandflag=0, map=XIL(0), prev_event=XIL(0),
    used_mouse_menu=0x0, end_time=0x7fffffff8050) at keyboard.c:2773
#50 0x0000000000646171 in read_filtered_event (no_switch_frame=false,
    ascii_required=false, error_nonascii=false, input_method=true,
    seconds=make_number(5)) at lread.c:678
#51 0x00000000006464ad in Fread_event (prompt=XIL(0),
    inherit_input_method=XIL(0xc150), seconds=make_number(5)) at lread.c:794
#52 0x000000000061869b in funcall_subr (subr=0xc7ec00 <Sread_event>, numargs=3,
    args=0x7fffffff8208) at eval.c:2934
#53 0x000000000061821c in Ffuncall (nargs=4, args=0x7fffffff8200) at eval.c:2854
#54 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x965774),
    vector=XIL(0x965795), maxdepth=make_number(7), args_template=make_number(769),
    nargs=1, args=0x7fffffff86e8) at bytecode.c:632
#55 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x965745), nargs=1,
    arg_vector=0x7fffffff86e0) at eval.c:3055
#56 0x0000000000618260 in Ffuncall (nargs=2, args=0x7fffffff86d8) at eval.c:2856
#57 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x1032ef4),
    vector=XIL(0x144cab5), maxdepth=make_number(8), args_template=make_number(514),
    nargs=2, args=0x7fffffff8bd0) at bytecode.c:632
#58 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x144cb15), nargs=2,
    arg_vector=0x7fffffff8bc0) at eval.c:3055
#59 0x0000000000618260 in Ffuncall (nargs=3, args=0x7fffffff8bb8) at eval.c:2856
#60 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x1032db4),
    vector=XIL(0x144c945), maxdepth=make_number(14),
    args_template=make_number(1799), nargs=7, args=0x7fffffff9168) at bytecode.c:632
#61 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x144ca85), nargs=7,
    arg_vector=0x7fffffff9130) at eval.c:3055
#62 0x0000000000618260 in Ffuncall (nargs=8, args=0x7fffffff9128) at eval.c:2856
#63 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x1032d04),
    vector=XIL(0x1313f35), maxdepth=make_number(8), args_template=make_number(0),
    nargs=0, args=0x7fffffff9600) at bytecode.c:632
#64 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x132c115), nargs=0,
    arg_vector=0x7fffffff9600) at eval.c:3055
#65 0x0000000000618260 in Ffuncall (nargs=1, args=0x7fffffff95f8) at eval.c:2856
#66 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x10323b4),
    vector=XIL(0x144a945), maxdepth=make_number(6), args_template=make_number(257),
    nargs=1, args=0x7fffffff9b30) at bytecode.c:632
#67 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x144a975), nargs=1,
    arg_vector=0x7fffffff9b28) at eval.c:3055
#68 0x0000000000618260 in Ffuncall (nargs=2, args=0x7fffffff9b20) at eval.c:2856
#69 0x0000000000664a25 in exec_byte_code (bytestr=XIL(0x10323d4),
    vector=XIL(0x144ba05), maxdepth=make_number(35),
    args_template=make_number(514), nargs=2, args=0x7fffffffa398) at bytecode.c:632
#70 0x0000000000618cb7 in funcall_lambda (fun=XIL(0x144bcb5), nargs=2,
    arg_vector=0x7fffffffa388) at eval.c:3055
#71 0x0000000000618260 in Ffuncall (nargs=3, args=0x7fffffffa380) at eval.c:2856
#72 0x0000000000617494 in Fapply (nargs=2, args=0x7fffffffa440) at eval.c:2474
#73 0x0000000000617a46 in apply1 (fn=XIL(0x33ef00), arg=XIL(0x1228df3))
    at eval.c:2690
#74 0x00000000006755b5 in read_process_output_call (fun_and_args=XIL(0x1228da3))
    at process.c:5807
#75 0x0000000000614990 in internal_condition_case_1 (
    bfun=0x675587 <read_process_output_call>, arg=XIL(0x1228da3),
    handlers=XIL(0x5340), hfun=0x6755b7 <read_process_output_error_handler>)
    at eval.c:1395
#76 0x0000000000675e56 in read_and_dispose_of_process_output (p=0x14385e0,
    chars=0x7fffffffa590 "id/Downloads/scala-2.8.1.final -env SDK=/home/jvshahid/Android/Sdk/ -env SHELL=/bin/zsh -env SHLVL=2 -env SSH_AUTH_SOCK=/home/jvshahid/.gnupg/S.gpg-agent.ssh -env TERM=screen-256color -env TMUX=/tmp/t"..., nbytes=1522,
    coding=0x10342b0) at process.c:6018
#77 0x0000000000675a77 in read_process_output (proc=XIL(0x14385e5), channel=9)
    at process.c:5929
#78 0x0000000000674e0c in wait_reading_process_output (time_limit=0, nsecs=0,
    read_kbd=-1, do_display=true, wait_for_cell=XIL(0), wait_proc=0x0,
    just_wait_proc=0) at process.c:5626
#79 0x0000000000570d03 in kbd_buffer_get_event (kbp=0x7fffffffbae8,
    used_mouse_menu=0x7fffffffc095, end_time=0x0) at keyboard.c:3816
#80 0x000000000056ce0d in read_event_from_main_queue (end_time=0x0,
    local_getcjmp=0x7fffffffbea0, used_mouse_menu=0x7fffffffc095) at keyboard.c:2122
#81 0x000000000056d0ca in read_decoded_event_from_main_queue (end_time=0x0,
    local_getcjmp=0x7fffffffbea0, prev_event=XIL(0), used_mouse_menu=0x7fffffffc095)
    at keyboard.c:2185
#82 0x000000000056e808 in read_char (commandflag=1, map=XIL(0x122bc83),
    prev_event=XIL(0), used_mouse_menu=0x7fffffffc095, end_time=0x0)
    at keyboard.c:2773
#83 0x000000000057b7cc in read_key_sequence (keybuf=0x7fffffffc2a0, prompt=XIL(0),
    dont_downcase_last=false, can_return_switch_frame=true,
    fix_current_buffer=true, prevent_redisplay=false) at keyboard.c:9121
#84 0x000000000056ad97 in command_loop_1 () at keyboard.c:1338
#85 0x00000000006148e9 in internal_condition_case (bfun=0x56a947 <command_loop_1>,
    handlers=XIL(0x5340), hfun=0x56a0f4 <cmd_error>) at eval.c:1371
#86 0x000000000056a63a in command_loop_2 (ignore=XIL(0)) at keyboard.c:1079
#87 0x000000000061416f in internal_catch (tag=XIL(0xc7e0),
    func=0x56a611 <command_loop_2>, arg=XIL(0)) at eval.c:1136
#88 0x000000000056a5dc in command_loop () at keyboard.c:1058
#89 0x0000000000569cc9 in recursive_edit_1 () at keyboard.c:703
#90 0x0000000000569e4b in Frecursive_edit () at keyboard.c:774
#91 0x0000000000567a49 in main (argc=4, argv=0x7fffffffc708) at emacs.c:1724

Lisp Backtrace:
"make-terminal-frame" (0xffff2b78)
"tty-create-frame-with-faces" (0xffff3088)
0x1309240 PVEC_COMPILED
"apply" (0xffff3690)
"frame-creation-function" (0xffff3ba0)
"make-frame" (0xffff4128)
"server-create-tty-frame" (0xffff4630)
0x1481990 PVEC_COMPILED
"server-execute" (0xffff50c0)
0x1481a80 PVEC_COMPILED
"server-execute-continuation" (0xffff5ab8)
"server-process-filter" (0xffff6318)
"read-event" (0xffff8208)
"sit-for" (0xffff86e0)
"server-return-error" (0xffff8bc0)
"server-execute" (0xffff9130)
0x132c110 PVEC_COMPILED
"server-execute-continuation" (0xffff9b28)
"server-process-filter" (0xffffa388)

In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2018-09-15 built on amun
Repository revision: f1ddaf7b65bb8edac41813b48f96a84c7fc2e263
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description: Linux Mint 18.3

Configured using:
 'configure --prefix=/home/jvshahid/bin/emacs-27 --with-xpm=no
 --with-jpeg=no --with-gif=no --with-tiff=no'

Configured features:
PNG SOUND DBUS GSETTINGS GLIB NOTIFY ACL LIBSELINUX GNUTLS LIBXML2
FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM THREADS GMP

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix