Subject: bug#28630: 27.0.50; C-g while a non-main thread is sitting crashes Emacs

From: Alex <[email-masked]>
Date: Thu, 28 Sep 2017 01:22:58 -0600

Evaluate the following in emacs -Q:

(make-thread
 (lambda ()
   (message "hello")
   (sit-for 2)
   (message "there")))

Executing C-g before this finishes crashes Emacs. Here's a backtrace:

#0  0x00007fffefa8bfcf in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007fffefa8d3fa in __GI_abort () at abort.c:89
#2  0x00007fffefac9bd0 in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7fffefbbd2c5 "*** %s ***: %s terminated\n") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007fffefb521b7 in __GI___fortify_fail (msg=0x7fffefbbd284 <longjmp_msg> "longjmp causes uninitialized stack frame") at fortify_fail.c:30
#4  0x00007fffefb520ed in ____longjmp_chk () at ../sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S:100
#5  0x00007fffefb5204b in __longjmp_chk (env=env@entry=0xbbd960 <getcjmp>, val=val@entry=1) at ../setjmp/longjmp.c:38
#6  0x00000000004f3007 in quit_throw_to_read_char (from_signal=from_signal@entry=false) at keyboard.c:10537
#7  0x0000000000501a4c in set_waiting_for_input (time_to_clear=time_to_clear@entry=0x7fffffffd940) at keyboard.c:10311
#8  0x00000000005a5d6d in wait_reading_process_output (time_limit=time_limit@entry=30, nsecs=nsecs@entry=0, read_kbd=read_kbd@entry=-1, do_display=do_display@entry=true, wait_for_cell=..., 
    wait_for_cell@entry=..., wait_proc=wait_proc@entry=0x0, just_wait_proc=0) at process.c:5172
#9  0x0000000000424000 in sit_for (timeout=..., reading=reading@entry=true, display_option=display_option@entry=1)
    at dispnew.c:5764
#10 0x00000000004fdeef in read_char (commandflag=commandflag@entry=1, map=..., 
    map@entry=..., prev_event=..., used_mouse_menu=used_mouse_menu@entry=0x7fffffffe31b, end_time=end_time@entry=0x0)
    at keyboard.c:2724
#11 0x00000000004feb2c in read_key_sequence (keybuf=keybuf@entry=0x7fffffffe420, prompt=..., 
    prompt@entry=..., 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 keyboard.c:9154
#12 0x0000000000500576 in command_loop_1 () at keyboard.c:1372
#13 0x000000000056495e in internal_condition_case (bfun=bfun@entry=0x500350 <command_loop_1>, handlers=..., 
    handlers@entry=..., hfun=hfun@entry=0x4f6eb0 <cmd_error>) at eval.c:1332
#14 0x00000000004f2444 in command_loop_2 (ignore=..., ignore@entry=...) at keyboard.c:1114
#15 0x00000000005648cd in internal_catch (tag=..., tag@entry=..., func=func@entry=0x4f2420 <command_loop_2>, arg=..., 
    arg@entry=...) at eval.c:1097
#16 0x00000000004f23db in command_loop () at keyboard.c:1093
#17 0x00000000004f6ac3 in recursive_edit_1 () at keyboard.c:699
#18 0x00000000004f6de6 in Frecursive_edit () at keyboard.c:770
#19 0x000000000041a3f1 in main (argc=<optimized out>,
#argv=0x7fffffffe7a8) at emacs.c:1713

In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.18)
 of 2017-09-28 built on lylat
Repository revision: 1f02ae39310f15bf683642b9aee1cf162bd391e6
Windowing system distributor 'The X.Org Foundation', version 11.0.11903000
System Description:	Debian GNU/Linux testing (buster)

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 LCMS2