Subject: bug#37892: 27.0.50; Crash when signaling a thread

From: Michał Krzywkowski <[email-masked]>
Date: Wed, 23 Oct 2019 19:06:42 +0200

Repository revision: b7037662e1111d55218fb2345f9ebb9ed3ebef13

When I evaluate this sexp, Emacs aborts:

  (let ((thread (make-thread (lambda () (sit-for 1.0)))))
    (sit-for 0.5)
    (thread-signal thread 'error nil))

Backtrace:

  Thread 5 "emacs" hit Breakpoint 1, terminate_due_to_signal (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=40) at emacs.c:371
  371       signal (sig, SIG_DFL);
  #0  0x000000000041f40b in terminate_due_to_signal (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=40) at emacs.c:371
  #1  0x000000000041f866 in emacs_abort () at sysdep.c:2450
  #2  0x000000000042154b in signal_or_quit (error_symbol=XIL(0x90), data=XIL(0), keyboard_quit=<optimized out>) at eval.c:1598
  #3  0x0000000000421564 in Fsignal (error_symbol=<optimized out>, data=<optimized out>) at eval.c:1568
  #4  0x0000000000423929 in post_acquire_global_lock (self=<optimized out>) at thread.c:115
  #5  0x00000000005c5e62 in acquire_global_lock (self=0x1465e50) at thread.c:123
  #6  0x00000000005c5e62 in really_call_select (arg=0x7fffee0253b0) at thread.c:596
  #7  0x00000000005c68c7 in thread_select
      (func=<optimized out>, max_fds=max_fds@entry=13, rfds=rfds@entry=0x7fffee025460, wfds=<optimized out>, efds=efds@entry=0x0, timeout=timeout@entry=0x7fffee025a50, sigmask=0x0) at thread.c:616
  #8  0x00000000005e3058 in xg_select (fds_lim=13, rfds=rfds@entry=0x7fffee025b80, wfds=wfds@entry=0x7fffee025c00, efds=efds@entry=0x0, timeout=timeout@entry=0x7fffee025a50, sigmask=sigmask@entry=0x0)
      at xgselect.c:73
  #9  0x00000000005a6fae in wait_reading_process_output
      (time_limit=<optimized out>, nsecs=<optimized out>, read_kbd=read_kbd@entry=-1, do_display=do_display@entry=true, wait_for_cell=wait_for_cell@entry=XIL(0), wait_proc=wait_proc@entry=0x0, just_wait_proc=0)
      at process.c:5519
  #10 0x0000000000503119 in kbd_buffer_get_event (end_time=0x7fffee026360, used_mouse_menu=0x0, kbp=<synthetic pointer>) at lisp.h:1032
  #11 0x0000000000503119 in read_event_from_main_queue (used_mouse_menu=0x0, local_getcjmp=0x7fffee026090, end_time=0x7fffee026360) at keyboard.c:2152
  #12 0x0000000000503119 in read_decoded_event_from_main_queue (used_mouse_menu=<optimized out>, prev_event=<optimized out>, local_getcjmp=<optimized out>, end_time=<optimized out>) at keyboard.c:2216
  #13 0x0000000000503119 in read_char (commandflag=commandflag@entry=0, map=map@entry=XIL(0), prev_event=prev_event@entry=XIL(0), used_mouse_menu=used_mouse_menu@entry=0x0, end_time=0x7fffee026360)
      at keyboard.c:2826
  #14 0x000000000058a51e in read_filtered_event (no_switch_frame=false, ascii_required=false, error_nonascii=false, input_method=<optimized out>, seconds=XIL(0xa8a86f)) at lisp.h:1032
  #15 0x000000000056a7e3 in Ffuncall (nargs=4, args=args@entry=0x7fffee026430) at lisp.h:2109
  #16 0x000000000059d2b1 in exec_byte_code (bytestr=<optimized out>, vector=<optimized out>, maxdepth=<optimized out>, args_template=<optimized out>, nargs=<optimized out>, args=<optimized out>) at bytecode.c:633
  #17 0x000000000056c250 in apply_lambda (fun=XIL(0x7ffff031e795), args=<optimized out>, count=count@entry=1) at eval.c:2926
  #18 0x000000000056c52b in eval_sub (form=<optimized out>) at eval.c:2348
  #19 0x000000000056cbed in Fprogn (body=XIL(0)) at eval.c:462
  #20 0x000000000056cbed in funcall_lambda (fun=XIL(0x12a7d23), nargs=0, arg_vector=0x1465e78) at eval.c:3060
  #21 0x000000000056a73f in Ffuncall (nargs=nargs@entry=1, args=args@entry=0x1465e70) at eval.c:2808
  #22 0x00000000005c61d8 in invoke_thread_function () at thread.c:702
  #23 0x0000000000569b12 in internal_condition_case (bfun=bfun@entry=0x5c61a0 <invoke_thread_function>, handlers=handlers@entry=XIL(0x30), hfun=hfun@entry=0x5c5bd0 <record_thread_error>) at eval.c:1355
  #24 0x00000000005c60c2 in run_thread (state=0x1465e50) at lisp.h:1032
  #25 0x00007ffff48e1fa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
  #26 0x00007ffff47254cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Full backtrace in attachment.

-- 
Michał Krzywkowski
PGP: A5A7 06C4 28EF 8F64 2868 13A1 7BDE C129 F0B8 09A1