unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#37892: 27.0.50; Crash when signaling a thread
@ 2019-10-23 17:06 Michał Krzywkowski
  2019-10-25  8:44 ` Eli Zaretskii
  2021-12-05  3:15 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 8+ messages in thread
From: Michał Krzywkowski @ 2019-10-23 17:06 UTC (permalink / raw)
  To: 37892


[-- Attachment #1.1: Type: text/plain, Size: 4058 bytes --]


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.


[-- Attachment #1.2: GDB logs --]
[-- Type: text/plain, Size: 34781 bytes --]

Warning: /home/michal/src/emacs/../lwlib: No such file or directory.
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not from terminal]
DISPLAY = :0.0
TERM = xterm-256color
Breakpoint 1 at 0x41f40b: file emacs.c, line 371.
Breakpoint 2 at 0x4cf6c0: file xterm.c, line 10142.
Starting program: /home/michal/src/emacs/src/emacs -Q
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffefec8700 (LWP 14827)]
[New Thread 0x7fffef565700 (LWP 14828)]
[New Thread 0x7fffeec69700 (LWP 14829)]
[New Thread 0x7fffee027700 (LWP 14830)]
[Switching to Thread 0x7fffee027700 (LWP 14830)]

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

Lisp Backtrace:
"read-event" (0xee026438)
"sit-for" (0xee0265c0)
0x12a7d20 Lisp type 3
#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
        conditions = <optimized out>
        string = <optimized out>
        real_error_symbol = XIL(0x90)
        clause = XIL(0)
        h = <optimized out>
#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
        sym = <optimized out>
        data = <optimized out>
        prev_thread = <optimized out>
#5  0x00000000005c5e62 in acquire_global_lock (self=0x1465e50) at thread.c:123
        sa = 0x7fffee0253b0
        self = 0x1465e50
        oldset = {
          __val = {0 <repeats 13 times>, 12, 140737186519936, 11534064}
        }
#6  0x00000000005c5e62 in really_call_select (arg=0x7fffee0253b0) at thread.c:596
        sa = 0x7fffee0253b0
        self = 0x1465e50
        oldset = {
          __val = {0 <repeats 13 times>, 12, 140737186519936, 11534064}
        }
#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
        sa = {
          func = 0x4192b0 <pselect@plt>, 
          max_fds = 13, 
          rfds = 0x7fffee025460, 
          wfds = 0x7fffee0254e0, 
          efds = 0x0, 
          timeout = 0x7fffee025a50, 
          sigmask = 0x0, 
          result = 0
        }
#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
        all_rfds = {
          fds_bits = {0 <repeats 16 times>}
        }
        all_wfds = {
          fds_bits = {0 <repeats 16 times>}
        }
        tmo = {
          tv_sec = 0, 
          tv_nsec = 0
        }
        tmop = <optimized out>
        context = 0xaffef0
        have_wfds = true
        gfds_buf = {{
            fd = 0, 
            events = 0, 
            revents = 0
          } <repeats 27 times>, {
            fd = -192834946, 
            events = 32767, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          }, {
            fd = 0, 
            events = 42256, 
            revents = 59604
          }, {
            fd = -301836384, 
            events = 32767, 
            revents = 0
          }, {
            fd = -671078080, 
            events = 32767, 
            revents = 0
          }, {
            fd = -40, 
            events = 0, 
            revents = 0
          }, {
            fd = 1, 
            events = 0, 
            revents = 0
          }, {
            fd = -301836416, 
            events = 32767, 
            revents = 0
          }, {
            fd = 2, 
            events = 0, 
            revents = 0
          }, {
            fd = -301836224, 
            events = 32767, 
            revents = 0
          }, {
            fd = -192760288, 
            events = 32767, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          } <repeats 14 times>, {
            fd = -301836224, 
            events = 32767, 
            revents = 0
          }, {
            fd = -301836384, 
            events = 32767, 
            revents = 0
          }, {
            fd = -671078080, 
            events = 32767, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          }, {
            fd = 8, 
            events = 0, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          }, {
            fd = 7, 
            events = 0, 
            revents = 0
          }, {
            fd = -172961280, 
            events = 24365, 
            revents = 9211
          }, {
            fd = 2, 
            events = 0, 
            revents = 0
          }, {
            fd = 1, 
            events = 0, 
            revents = 0
          }, {
            fd = 2, 
            events = 0, 
            revents = 0
          }, {
            fd = -301836224, 
            events = 32767, 
            revents = 0
          }, {
            fd = 10480576, 
            events = 0, 
            revents = 0
          }, {
            fd = -301836176, 
            events = 32767, 
            revents = 0
          }, {
            fd = -301836240, 
            events = 32767, 
            revents = 0
          }, {
            fd = -192862136, 
            events = 32767, 
            revents = 0
          }, {
            fd = 1, 
            events = 0, 
            revents = 0
          }, {
            fd = -192861830, 
            events = 32767, 
            revents = 0
          }, {
            fd = 296615936, 
            events = 9542, 
            revents = 62036
          }, {
            fd = -689186644, 
            events = 19, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          }, {
            fd = -671088608, 
            events = 32767, 
            revents = 0
          }, {
            fd = 2, 
            events = 0, 
            revents = 0
          }, {
            fd = 18765568, 
            events = 0, 
            revents = 0
          }, {
            fd = 2, 
            events = 0, 
            revents = 0
          }, {
            fd = 2, 
            events = 0, 
            revents = 0
          }, {
            fd = 1, 
            events = 2, 
            revents = 0
          }, {
            fd = -671078080, 
            events = 32767, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          }, {
            fd = -172961280, 
            events = 24365, 
            revents = 9211
          }, {
            fd = 21389736, 
            events = 0, 
            revents = 0
          }, {
            fd = 10480576, 
            events = 0, 
            revents = 0
          }, {
            fd = 2, 
            events = 0, 
            revents = 0
          }, {
            fd = 1, 
            events = 0, 
            revents = 0
          }, {
            fd = 10480576, 
            events = 0, 
            revents = 0
          }, {
            fd = -192834946, 
            events = 32767, 
            revents = 0
          }, {
            fd = -301836112, 
            events = 32767, 
            revents = 0
          }, {
            fd = 0, 
            events = 10240, 
            revents = 61035
          }, {
            fd = -671078080, 
            events = 32767, 
            revents = 0
          }, {
            fd = -671078080, 
            events = 32767, 
            revents = 0
          }, {
            fd = -30, 
            events = 0, 
            revents = 0
          }, {
            fd = 1, 
            events = 0, 
            revents = 0
          }, {
            fd = 1, 
            events = 0, 
            revents = 0
          }, {
            fd = 10480576, 
            events = 0, 
            revents = 0
          }, {
            fd = -671078080, 
            events = 32767, 
            revents = 0
          }, {
            fd = -192908175, 
            events = 32767, 
            revents = 0
          }, {
            fd = 95938, 
            events = 0, 
            revents = 0
          }, {
            fd = -727379968, 
            events = 232, 
            revents = 0
          }, {
            fd = 14713253, 
            events = 0, 
            revents = 0
          }, {
            fd = 5321588, 
            events = 0, 
            revents = 0
          }, {
            fd = 661861600, 
            events = 0, 
            revents = 0
          }, {
            fd = 14713253, 
            events = 0, 
            revents = 0
          }, {
            fd = 1, 
            events = 0, 
            revents = 0
          }, {
            fd = 5973967, 
            events = 0, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          }, {
            fd = 1571850000, 
            events = 0, 
            revents = 0
          }, {
            fd = -301835968, 
            events = 32767, 
            revents = 0
          }, {
            fd = 5979851, 
            events = 0, 
            revents = 0
          }, {
            fd = 21389733, 
            events = 0, 
            revents = 0
          }, {
            fd = 1385447426, 
            events = 931, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          }, {
            fd = 5236159, 
            events = 0, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          }, {
            fd = 19562355, 
            events = 0, 
            revents = 0
          }, {
            fd = 0, 
            events = 0, 
            revents = 0
          }, {
            fd = 3, 
            events = 0, 
            revents = 0
          }, {
            fd = 1571849996, 
            events = 0, 
            revents = 0
          }, {
            fd = 687585021, 
            events = 0, 
            revents = 0
          }, {
            fd = 19562355, 
            events = 0, 
            revents = 0
          }, {
            fd = 19562352, 
            events = 0, 
            revents = 0
          }, {
            fd = 1571850000, 
            events = 0, 
            revents = 0
          }, {
            fd = 661861600, 
            events = 0, 
            revents = 0
          }, {
            fd = -301835904, 
            events = 32767, 
            revents = 0
          }, {
            fd = -193777674, 
            events = 32767, 
            revents = 0
          }}
        gfds = 0x7fffee025560
        gfds_size = 128
        n_gfds = <optimized out>
        retval = 0
        our_fds = 0
        max_fds = 12
        context_acquired = false
        i = <optimized out>
        nfds = <optimized out>
        tmo_in_millisec = 0
        must_free = 0
        need_to_dispatch = <optimized out>
#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
        process_skipped = <optimized out>
        channel = <optimized out>
        nfds = <optimized out>
        Available = {
          fds_bits = {0 <repeats 16 times>}
        }
        Writeok = {
          fds_bits = {0 <repeats 16 times>}
        }
        check_write = <optimized out>
        check_delay = <optimized out>
        no_avail = false
        xerrno = -671084448
        proc = <optimized out>
        timeout = {
          tv_sec = 0, 
          tv_nsec = 0
        }
        end_time = <optimized out>
        timer_delay = <optimized out>
        got_output_end_time = {
          tv_sec = 0, 
          tv_nsec = -1
        }
        wait = TIMEOUT
        got_some_output = -1
        prev_wait_proc_nbytes_read = 0
        retry_for_async = <optimized out>
        count = 5
        now = <optimized out>
#10 0x0000000000503119 in kbd_buffer_get_event (end_time=0x7fffee026360, used_mouse_menu=0x0, kbp=<synthetic pointer>) at lisp.h:1032
        now = <optimized out>
        obj = <optimized out>
        c = XIL(0)
        count = 4
        save_jump = {{
            __jmpbuf = {0, 0, 0, 0, 0, 0, 0, 0}, 
            __mask_was_saved = 0, 
            __saved_mask = {
              __val = {0 <repeats 16 times>}
            }
          }}
        kb = <optimized out>
        nextevt = <optimized out>
        frame = <optimized out>
        terminal = <optimized out>
        events = {XIL(0xffffffd8), XIL(0x1), XIL(0x7fffee026130), make_fixnum(0), XIL(0x7fffee0261f0), XIL(0x7ffff482b620), XIL(0xffffffd8), XIL(0x1), XIL(0x7fffee026160), make_fixnum(0), XIL(0x7fffee026220), XIL(0x7ffff482b620), XIL(0), XIL(0), XIL(0), XIL(0)}
        n = 0
        c = <optimized out>
        jmpcount = 4
        local_getcjmp = {{
            __jmpbuf = {10513216, -5446370651149326792, 0, 0, -4611686018813263872, 11053167, 5446338396274533944, -5446370036827969992}, 
            __mask_was_saved = 0, 
            __saved_mask = {
              __val = {0, 8, 0, 7, 2592770661482025472, 2, 1, 2, 140737186521584, 10480576, 140737186521632, 140737186521568, 140737296384988, 1, 18446744073709551615, 11387872}
            }
          }}
        save_jump = {{
            __jmpbuf = {11387896, 140737326555575, 2, 11392168, 2, 2, -1, 7918849472}, 
            __mask_was_saved = 11387988, 
            __saved_mask = {
              __val = {4096, 0, 0, 140737186521504, 1, 140737186521584, 80, 0, 17179869184000000000, 140736817270208, 140736817270208, 4294967266, 1, 1, 10480576, 140736817270208}
            }
          }}
        tem = <optimized out>
        save = <optimized out>
        previous_echo_area_message = XIL(0)
        also_record = XIL(0)
        reread = false
        recorded = false
        polling_stopped_here = true
        orig_kboard = 0xb2e7c0
#11 0x0000000000503119 in read_event_from_main_queue (used_mouse_menu=0x0, local_getcjmp=0x7fffee026090, end_time=0x7fffee026360) at keyboard.c:2152
        c = XIL(0)
        count = 4
        save_jump = {{
            __jmpbuf = {0, 0, 0, 0, 0, 0, 0, 0}, 
            __mask_was_saved = 0, 
            __saved_mask = {
              __val = {0 <repeats 16 times>}
            }
          }}
        kb = <optimized out>
        nextevt = <optimized out>
        frame = <optimized out>
        terminal = <optimized out>
        events = {XIL(0xffffffd8), XIL(0x1), XIL(0x7fffee026130), make_fixnum(0), XIL(0x7fffee0261f0), XIL(0x7ffff482b620), XIL(0xffffffd8), XIL(0x1), XIL(0x7fffee026160), make_fixnum(0), XIL(0x7fffee026220), XIL(0x7ffff482b620), XIL(0), XIL(0), XIL(0), XIL(0)}
        n = 0
        c = <optimized out>
        jmpcount = 4
        local_getcjmp = {{
            __jmpbuf = {10513216, -5446370651149326792, 0, 0, -4611686018813263872, 11053167, 5446338396274533944, -5446370036827969992}, 
            __mask_was_saved = 0, 
            __saved_mask = {
              __val = {0, 8, 0, 7, 2592770661482025472, 2, 1, 2, 140737186521584, 10480576, 140737186521632, 140737186521568, 140737296384988, 1, 18446744073709551615, 11387872}
            }
          }}
        save_jump = {{
            __jmpbuf = {11387896, 140737326555575, 2, 11392168, 2, 2, -1, 7918849472}, 
            __mask_was_saved = 11387988, 
            __saved_mask = {
              __val = {4096, 0, 0, 140737186521504, 1, 140737186521584, 80, 0, 17179869184000000000, 140736817270208, 140736817270208, 4294967266, 1, 1, 10480576, 140736817270208}
            }
          }}
        tem = <optimized out>
        save = <optimized out>
        previous_echo_area_message = XIL(0)
        also_record = XIL(0)
        reread = false
        recorded = false
        polling_stopped_here = true
        orig_kboard = 0xb2e7c0
#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
        nextevt = <optimized out>
        frame = <optimized out>
        terminal = <optimized out>
        events = {XIL(0xffffffd8), XIL(0x1), XIL(0x7fffee026130), make_fixnum(0), XIL(0x7fffee0261f0), XIL(0x7ffff482b620), XIL(0xffffffd8), XIL(0x1), XIL(0x7fffee026160), make_fixnum(0), XIL(0x7fffee026220), XIL(0x7ffff482b620), XIL(0), XIL(0), XIL(0), XIL(0)}
        n = 0
        c = <optimized out>
        jmpcount = 4
        local_getcjmp = {{
            __jmpbuf = {10513216, -5446370651149326792, 0, 0, -4611686018813263872, 11053167, 5446338396274533944, -5446370036827969992}, 
            __mask_was_saved = 0, 
            __saved_mask = {
              __val = {0, 8, 0, 7, 2592770661482025472, 2, 1, 2, 140737186521584, 10480576, 140737186521632, 140737186521568, 140737296384988, 1, 18446744073709551615, 11387872}
            }
          }}
        save_jump = {{
            __jmpbuf = {11387896, 140737326555575, 2, 11392168, 2, 2, -1, 7918849472}, 
            __mask_was_saved = 11387988, 
            __saved_mask = {
              __val = {4096, 0, 0, 140737186521504, 1, 140737186521584, 80, 0, 17179869184000000000, 140736817270208, 140736817270208, 4294967266, 1, 1, 10480576, 140736817270208}
            }
          }}
        tem = <optimized out>
        save = <optimized out>
        previous_echo_area_message = XIL(0)
        also_record = XIL(0)
        reread = false
        recorded = false
        polling_stopped_here = true
        orig_kboard = 0xb2e7c0
#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
        c = <optimized out>
        jmpcount = 4
        local_getcjmp = {{
            __jmpbuf = {10513216, -5446370651149326792, 0, 0, -4611686018813263872, 11053167, 5446338396274533944, -5446370036827969992}, 
            __mask_was_saved = 0, 
            __saved_mask = {
              __val = {0, 8, 0, 7, 2592770661482025472, 2, 1, 2, 140737186521584, 10480576, 140737186521632, 140737186521568, 140737296384988, 1, 18446744073709551615, 11387872}
            }
          }}
        save_jump = {{
            __jmpbuf = {11387896, 140737326555575, 2, 11392168, 2, 2, -1, 7918849472}, 
            __mask_was_saved = 11387988, 
            __saved_mask = {
              __val = {4096, 0, 0, 140737186521504, 1, 140737186521584, 80, 0, 17179869184000000000, 140736817270208, 140736817270208, 4294967266, 1, 1, 10480576, 140736817270208}
            }
          }}
        tem = <optimized out>
        save = <optimized out>
        previous_echo_area_message = XIL(0)
        also_record = XIL(0)
        reread = false
        recorded = false
        polling_stopped_here = true
        orig_kboard = 0xb2e7c0
#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
        val = <optimized out>
        delayed_switch_frame = XIL(0)
        end_time = {
          tv_sec = 1571849997, 
          tv_nsec = 687546153
        }
#15 0x000000000056a7e3 in Ffuncall (nargs=4, args=args@entry=0x7fffee026430) at lisp.h:2109
        fun = <optimized out>
        original_fun = XIL(0x7fffef915888)
        funcar = <optimized out>
        numargs = 3
        val = <optimized out>
        count = 3
#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
        op = <optimized out>
        type = <optimized out>
        targets = {0x59f473 <exec_byte_code+9491>, 0x59dab4 <exec_byte_code+2900>, 0x59da7c <exec_byte_code+2844>, 0x59da77 <exec_byte_code+2839>, 0x59d373 <exec_byte_code+1043>, 0x59d373 <exec_byte_code+1043>, 0x59da41 <exec_byte_code+2785>, 0x59da01 <exec_byte_code+2721>, 0x59d616 <exec_byte_code+1718>, 0x59d611 <exec_byte_code+1713>, 0x59d60c <exec_byte_code+1708>, 0x59d663 <exec_byte_code+1795>, 0x59d36b <exec_byte_code+1035>, 0x59d36b <exec_byte_code+1035>, 0x59d3e8 <exec_byte_code+1160>, 0x59d1d8 <exec_byte_code+632>, 0x59d404 <exec_byte_code+1188>, 0x59d3fa <exec_byte_code+1178>, 0x59d3ff <exec_byte_code+1183>, 0x59d3f5 <exec_byte_code+1173>, 0x59d2ce <exec_byte_code+878>, 0x59d2ce <exec_byte_code+878>, 0x59d4ef <exec_byte_code+1423>, 0x59d4fc <exec_byte_code+1436>, 0x59d4ea <exec_byte_code+1418>, 0x59d5c6 <exec_byte_code+1638>, 0x59d5c1 <exec_byte_code+1633>, 0x59d5bc <exec_byte_code+1628>, 0x59d32f <exec_byte_code+975>, 0x59d32f <exec_byte_code+975>, 0x59d513 <exec_byte_code+1459>, 0x59d54c <exec_byte_code+1516>, 0x59d5aa <exec_byte_code+1610>, 0x59d5a5 <exec_byte_code+1605>, 0x59d5a0 <exec_byte_code+1600>, 0x59d57f <exec_byte_code+1567>, 0x59d291 <exec_byte_code+817>, 0x59d291 <exec_byte_code+817>, 0x59d5af <exec_byte_code+1615>, 0x59d3d1 <exec_byte_code+1137>, 0x59d58e <exec_byte_code+1582>, 0x59d589 <exec_byte_code+1577>, 0x59d584 <exec_byte_code+1572>, 0x59d563 <exec_byte_code+1539>, 0x59d246 <exec_byte_code+742>, 0x59d246 <exec_byte_code+742>, 0x59d593 <exec_byte_code+1587>, 0x59d568 <exec_byte_code+1544>, 0x59ee03 <exec_byte_code+7843>, 0x59ee30 <exec_byte_code+7888>, 0x59ee90 <exec_byte_code+7984>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59ef83 <exec_byte_code+8227>, 0x59ef46 <exec_byte_code+8166>, 0x59f0cd <exec_byte_code+8557>, 0x59f08d <exec_byte_code+8493>, 0x59ebb1 <exec_byte_code+7249>, 0x59d475 <exec_byte_code+1301>, 0x59d43c <exec_byte_code+1244>, 0x59eb86 <exec_byte_code+7206>, 0x59d4b7 <exec_byte_code+1367>, 0x59d409 <exec_byte_code+1193>, 0x59eb4d <exec_byte_code+7149>, 0x59ebef <exec_byte_code+7311>, 0x59eb14 <exec_byte_code+7092>, 0x59eade <exec_byte_code+7038>, 0x59eaa4 <exec_byte_code+6980>, 0x59ea39 <exec_byte_code+6873>, 0x59ea00 <exec_byte_code+6816>, 0x59e967 <exec_byte_code+6663>, 0x59e9d7 <exec_byte_code+6775>, 0x59e93e <exec_byte_code+6622>, 0x59e905 <exec_byte_code+6565>, 0x59e8cc <exec_byte_code+6508>, 0x59e893 <exec_byte_code+6451>, 0x59e856 <exec_byte_code+6390>, 0x59e823 <exec_byte_code+6339>, 0x59e7ae <exec_byte_code+6222>, 0x59e9a4 <exec_byte_code+6724>, 0x59e759 <exec_byte_code+6137>, 0x59e704 <exec_byte_code+6052>, 0x59e6c9 <exec_byte_code+5993>, 0x59e68b <exec_byte_code+5931>, 0x59e64d <exec_byte_code+5869>, 0x59e5d1 <exec_byte_code+5745>, 0x59e60f <exec_byte_code+5807>, 0x59e59e <exec_byte_code+5694>, 0x59e548 <exec_byte_code+5608>, 0x59e515 <exec_byte_code+5557>, 0x59e4e2 <exec_byte_code+5506>, 0x59e304 <exec_byte_code+5028>, 0x59e2d1 <exec_byte_code+4977>, 0x59e25b <exec_byte_code+4859>, 0x59d3a5 <exec_byte_code+1093>, 0x59e232 <exec_byte_code+4818>, 0x59e204 <exec_byte_code+4772>, 0x59e17f <exec_byte_code+4639>, 0x59e13c <exec_byte_code+4572>, 0x59e0e8 <exec_byte_code+4488>, 0x59e111 <exec_byte_code+4529>, 0x59e0bd <exec_byte_code+4445>, 0x59e08a <exec_byte_code+4394>, 0x59e05f <exec_byte_code+4351>, 0x59f473 <exec_byte_code+9491>, 0x59e034 <exec_byte_code+4308>, 0x59e009 <exec_byte_code+4265>, 0x59e3c8 <exec_byte_code+5224>, 0x59e39d <exec_byte_code+5181>, 0x59e47e <exec_byte_code+5406>, 0x59e374 <exec_byte_code+5140>, 0x59d3a5 <exec_byte_code+1093>, 0x59f473 <exec_byte_code+9491>, 0x59e337 <exec_byte_code+5079>, 0x59e41c <exec_byte_code+5308>, 0x59e3f3 <exec_byte_code+5267>, 0x59e445 <exec_byte_code+5349>, 0x59dfd0 <exec_byte_code+4208>, 0x59df82 <exec_byte_code+4130>, 0x59dfab <exec_byte_code+4171>, 0x59df49 <exec_byte_code+4073>, 0x59df10 <exec_byte_code+4016>, 0x59ded7 <exec_byte_code+3959>, 0x59deac <exec_byte_code+3916>, 0x59de5a <exec_byte_code+3834>, 0x59f473 <exec_byte_code+9491>, 0x59d753 <exec_byte_code+2035>, 0x59d668 <exec_byte_code+1800>, 0x59d5cb <exec_byte_code+1643>, 0x59ed15 <exec_byte_code+7605>, 0x59ecda <exec_byte_code+7546>, 0x59ec9f <exec_byte_code+7487>, 0x59d7ae <exec_byte_code+2126>, 0x59d78f <exec_byte_code+2095>, 0x59d520 <exec_byte_code+1472>, 0x59d734 <exec_byte_code+2004>, 0x59ee98 <exec_byte_code+7992>, 0x59d708 <exec_byte_code+1960>, 0x59ef08 <exec_byte_code+8104>, 0x59edb7 <exec_byte_code+7767>, 0x59ed7a <exec_byte_code+7706>, 0x59efd4 <exec_byte_code+8308>, 0x59f017 <exec_byte_code+8375>, 0x59ed56 <exec_byte_code+7670>, 0x59de1d <exec_byte_code+3773>, 0x59ddf4 <exec_byte_code+3732>, 0x59de83 <exec_byte_code+3875>, 0x59ddcb <exec_byte_code+3691>, 0x59dda2 <exec_byte_code+3650>, 0x59dd69 <exec_byte_code+3593>, 0x59dd30 <exec_byte_code+3536>, 0x59dcf7 <exec_byte_code+3479>, 0x59dcbe <exec_byte_code+3422>, 0x59dc2d <exec_byte_code+3277>, 0x59dc85 <exec_byte_code+3365>, 0x59dbf4 <exec_byte_code+3220>, 0x59dbcb <exec_byte_code+3179>, 0x59db92 <exec_byte_code+3122>, 0x59db59 <exec_byte_code+3065>, 0x59db23 <exec_byte_code+3011>, 0x59daed <exec_byte_code+2957>, 0x59da81 <exec_byte_code+2849>, 0x59e29e <exec_byte_code+4926>, 0x59e4a9 <exec_byte_code+5449>, 0x59d61b <exec_byte_code+1723>, 0x59dab9 <exec_byte_code+2905>, 0x59f473 <exec_byte_code+9491>, 0x59ec8e <exec_byte_code+7470>, 0x59ec53 <exec_byte_code+7411>, 0x59ec18 <exec_byte_code+7352>, 0x59d832 <exec_byte_code+2258>, 0x59d867 <exec_byte_code+2311>, 0x59ea62 <exec_byte_code+6914>, 0x59e7e1 <exec_byte_code+6273>, 0x59e1c2 <exec_byte_code+4706>, 0x59d9c0 <exec_byte_code+2656>, 0x59d973 <exec_byte_code+2579>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59d931 <exec_byte_code+2513>, 0x59d8ca <exec_byte_code+2410>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59f473 <exec_byte_code+9491>, 0x59d89c <exec_byte_code+2364> <repeats 64 times>}
        const_length = <optimized out>
        bytestr_length = <optimized out>
        vectorp = <optimized out>
        quitcounter = 1 '\001'
        stack_items = <optimized out>
        sa_avail = <optimized out>
        sa_count = <optimized out>
        alloc = <optimized out>
        item_bytes = <optimized out>
        stack_base = <optimized out>
        top = 0x7fffee026430
        stack_lim = <optimized out>
        bytestr_data = <optimized out>
        pc = <optimized out>
        count = 2
        result = <optimized out>
#17 0x000000000056c250 in apply_lambda (fun=XIL(0x7ffff031e795), args=<optimized out>, count=count@entry=1) at eval.c:2926
        arg_vector = 0x7fffee0265c0
        tem = <optimized out>
        sa_avail = <optimized out>
        sa_count = 2
        numargs = 1
        args_left = <optimized out>
#18 0x000000000056c52b in eval_sub (form=<optimized out>) at eval.c:2348
        original_fun = XIL(0x7fffef9157c0)
        original_args = XIL(0x12a83b3)
        count = 1
        fun = <optimized out>
        val = <optimized out>
        funcar = <optimized out>
        argvals = {XIL(0), XIL(0), XIL(0), XIL(0), XIL(0), XIL(0), XIL(0), XIL(0)}
#19 0x000000000056cbed in Fprogn (body=XIL(0)) at eval.c:462
        form = <optimized out>
        form = <optimized out>
        val = XIL(0)
        val = <optimized out>
        syms_left = XIL(0)
        next = <optimized out>
        lexenv = XIL(0)
        i = <optimized out>
        optional = <optimized out>
        rest = <optimized out>
#20 0x000000000056cbed in funcall_lambda (fun=XIL(0x12a7d23), nargs=0, arg_vector=0x1465e78) at eval.c:3060
        val = <optimized out>
        syms_left = XIL(0)
        next = <optimized out>
        lexenv = XIL(0)
        i = <optimized out>
        optional = <optimized out>
        rest = <optimized out>
#21 0x000000000056a73f in Ffuncall (nargs=nargs@entry=1, args=args@entry=0x1465e70) at eval.c:2808
        fun = <optimized out>
        original_fun = XIL(0x12a7d23)
        funcar = <optimized out>
        numargs = 0
        val = <optimized out>
        count = 0
#22 0x00000000005c61d8 in invoke_thread_function () at thread.c:702
        count = 0
#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
        val = <optimized out>
        c = 0x7fffd8000c50
#24 0x00000000005c60c2 in run_thread (state=0x1465e50) at lisp.h:1032
        stack_pos = {
          __max_align_ll = 0, 
          __max_align_ld = 0
        }
        self = 0x1465e50
        iter = <optimized out>
#25 0x00007ffff48e1fa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
        ret = <optimized out>
        pd = <optimized out>
        now = <optimized out>
        unwind_buf = {
          cancel_jmp_buf = {{
              jmp_buf = {140737186526976, -5446369348968798664, 140737488342574, 140737488342575, 140737186526976, 140737488342944, 5446338395655874104, 5446385711734433336}, 
              mask_was_saved = 0
            }}, 
          priv = {
            pad = {0x0, 0x0, 0x0, 0x0}, 
            data = {
              prev = 0x0, 
              cleanup = 0x0, 
              canceltype = 0
            }
          }
        }
        not_first_call = <optimized out>
#26 0x00007ffff47254cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Lisp Backtrace:
"read-event" (0xee026438)
"sit-for" (0xee0265c0)
0x12a7d20 Lisp type 3
[Inferior 1 (process 14823) killed]

[-- Attachment #1.3: Type: text/plain, Size: 86 bytes --]


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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#37892: 27.0.50; Crash when signaling a thread
  2019-10-23 17:06 bug#37892: 27.0.50; Crash when signaling a thread Michał Krzywkowski
@ 2019-10-25  8:44 ` Eli Zaretskii
  2019-10-26 12:29   ` Michał Krzywkowski
  2021-12-05  3:15 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2019-10-25  8:44 UTC (permalink / raw)
  To: Michał Krzywkowski; +Cc: 37892

> From: Michał Krzywkowski <mkrzywkow@gmail.com>
> Date: Wed, 23 Oct 2019 19:06:42 +0200
> 
> 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

Emacs doesn't allow signals while it waits for input.

We could ignore thread-signal in such cases, or we could make it an
error (which will then signal an error in the thread which called
thread-signal).  What do people think?  Are there any other ideas for
handling this situation?

Michał, can you tell why you needed to call thread-signal while the
thread was in sit-for?

Thanks.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#37892: 27.0.50; Crash when signaling a thread
  2019-10-25  8:44 ` Eli Zaretskii
@ 2019-10-26 12:29   ` Michał Krzywkowski
  2019-10-26 12:58     ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Michał Krzywkowski @ 2019-10-26 12:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 37892, Michał Krzywkowski

[-- Attachment #1: Type: text/plain, Size: 2213 bytes --]


>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
    >> From: Michał Krzywkowski <mkrzywkow@gmail.com>

    >> Date: Wed, 23 Oct 2019 19:06:42 +0200
    >>
    >> 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

    Eli> Emacs doesn't allow signals while it waits for input.

    Eli> We could ignore thread-signal in such cases, or we could make it an
    Eli> error (which will then signal an error in the thread which called
    Eli> thread-signal).  What do people think?  Are there any other ideas for
    Eli> handling this situation?

Maybe the signal should be raised in the thread right after it returns
from sit-for?  Ignoring signals sounds like a bad idea.

    Eli> Michał, can you tell why you needed to call thread-signal while the
    Eli> thread was in sit-for?

I wanted to signal some background thread which was doing some work and
then Emacs crashed, because it just so happened that it was in sit-for.
The thread function was doing _more_ than just sit-for.

I actually don't care (and can't know) what another thread is doing, I
just want to send a signal to it.

    Eli> Thanks.

Thank you.


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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#37892: 27.0.50; Crash when signaling a thread
  2019-10-26 12:29   ` Michał Krzywkowski
@ 2019-10-26 12:58     ` Eli Zaretskii
  2019-10-27 10:16       ` Michał Krzywkowski
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2019-10-26 12:58 UTC (permalink / raw)
  To: Michał Krzywkowski; +Cc: 37892

> From: Michał Krzywkowski <mkrzywkow@gmail.com>
> Cc: Michał Krzywkowski <mkrzywkow@gmail.com>,
>  37892@debbugs.gnu.org
> Date: Sat, 26 Oct 2019 14:29:43 +0200
> 
>     Eli> Emacs doesn't allow signals while it waits for input.
> 
>     Eli> We could ignore thread-signal in such cases, or we could make it an
>     Eli> error (which will then signal an error in the thread which called
>     Eli> thread-signal).  What do people think?  Are there any other ideas for
>     Eli> handling this situation?
> 
> Maybe the signal should be raised in the thread right after it returns
> from sit-for?

We don't have any mechanism for doing that.

> Ignoring signals sounds like a bad idea.

It is better than crashing.  It is also not much worse than
interrupting the thread at some arbitrary random point.

>     Eli> Michał, can you tell why you needed to call thread-signal while the
>     Eli> thread was in sit-for?
> 
> I wanted to signal some background thread which was doing some work and
> then Emacs crashed, because it just so happened that it was in sit-for.
> The thread function was doing _more_ than just sit-for.
> 
> I actually don't care (and can't know) what another thread is doing, I
> just want to send a signal to it.

But thread-signal is not for causing an error in a thread, it is for
unblocking a thread that waits on a mutex or a condvar.  So why would
you use it when the thread is not blocked?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#37892: 27.0.50; Crash when signaling a thread
  2019-10-26 12:58     ` Eli Zaretskii
@ 2019-10-27 10:16       ` Michał Krzywkowski
  2019-10-27 13:25         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Michał Krzywkowski @ 2019-10-27 10:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 37892, Michał Krzywkowski

[-- Attachment #1: Type: text/plain, Size: 1412 bytes --]


>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
    Eli> Michał, can you tell why you needed to call thread-signal while the
    Eli> thread was in sit-for?
    >>
    >> I wanted to signal some background thread which was doing some work and
    >> then Emacs crashed, because it just so happened that it was in sit-for.
    >> The thread function was doing _more_ than just sit-for.
    >>
    >> I actually don't care (and can't know) what another thread is doing, I
    >> just want to send a signal to it.

    Eli> But thread-signal is not for causing an error in a thread, it is for
    Eli> unblocking a thread that waits on a mutex or a condvar.  So why would
    Eli> you use it when the thread is not blocked?


Then I think documentation for that function should be changed to
explicitly say that the signal will *only* be delivered if the target
thread is in a "blocked call to ‘mutex-lock’, ‘condition-wait’, or
‘thread-join’".

Currently, the docstring of thread-signal just says that the function
will interrupt threads which are blocked, but does not actually say that
the signal will be delivered only in those cases.  In fact, it says that
it works like signal, so I don't think it's unreasonable to assume that
it will just interrupt a thread whatever it's doing.

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#37892: 27.0.50; Crash when signaling a thread
  2019-10-27 10:16       ` Michał Krzywkowski
@ 2019-10-27 13:25         ` Eli Zaretskii
  2019-10-27 19:26           ` Michał Krzywkowski
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2019-10-27 13:25 UTC (permalink / raw)
  To: Michał Krzywkowski; +Cc: 37892

> From: Michał Krzywkowski <mkrzywkow@gmail.com>
> Cc: Michał Krzywkowski <mkrzywkow@gmail.com>,
>  37892@debbugs.gnu.org
> Date: Sun, 27 Oct 2019 11:16:03 +0100
> 
>     >> I actually don't care (and can't know) what another thread is doing, I
>     >> just want to send a signal to it.
> 
>     Eli> But thread-signal is not for causing an error in a thread, it is for
>     Eli> unblocking a thread that waits on a mutex or a condvar.  So why would
>     Eli> you use it when the thread is not blocked?
> 
> Then I think documentation for that function should be changed to
> explicitly say that the signal will *only* be delivered if the target
> thread is in a "blocked call to ‘mutex-lock’, ‘condition-wait’, or
> ‘thread-join’".
> 
> Currently, the docstring of thread-signal just says that the function
> will interrupt threads which are blocked, but does not actually say that
> the signal will be delivered only in those cases.  In fact, it says that
> it works like signal, so I don't think it's unreasonable to assume that
> it will just interrupt a thread whatever it's doing.

The function does work like a signal, but Emacs cannot be interrupted
while it waits for input.  In all other cases your signal will be
delivered, and if unhandled, it will terminate the thread.

If we decide that thread-signal will have no effect while a thread
waits for input, then we will document that, of course.  My question
was meant to understand your intent for signaling a thread at
arbitrary time, because the effect of that is unpredictable, even if
the crash didn't happen.  I wanted to understand your thinking and
rationale, so as to have a better basis for the decision of how to fix
this problem.

So could you please elaborate on your rationale?

Thanks.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#37892: 27.0.50; Crash when signaling a thread
  2019-10-27 13:25         ` Eli Zaretskii
@ 2019-10-27 19:26           ` Michał Krzywkowski
  0 siblings, 0 replies; 8+ messages in thread
From: Michał Krzywkowski @ 2019-10-27 19:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 37892, Michał Krzywkowski

[-- Attachment #1: Type: text/plain, Size: 2213 bytes --]


>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
    Eli> But thread-signal is not for causing an error in a thread, it is for
    Eli> unblocking a thread that waits on a mutex or a condvar.  So why would
    Eli> you use it when the thread is not blocked?
    >>
    >> Then I think documentation for that function should be changed to
    >> explicitly say that the signal will *only* be delivered if the target
    >> thread is in a "blocked call to ‘mutex-lock’, ‘condition-wait’, or
    >> ‘thread-join’".
    >>
    >> Currently, the docstring of thread-signal just says that the function
    >> will interrupt threads which are blocked, but does not actually say that
    >> the signal will be delivered only in those cases.  In fact, it says that
    >> it works like signal, so I don't think it's unreasonable to assume that
    >> it will just interrupt a thread whatever it's doing.

    Eli> The function does work like a signal, but Emacs cannot be interrupted
    Eli> while it waits for input.  In all other cases your signal will be
    Eli> delivered, and if unhandled, it will terminate the thread.

    Eli> If we decide that thread-signal will have no effect while a thread
    Eli> waits for input, then we will document that, of course.  My question
    Eli> was meant to understand your intent for signaling a thread at
    Eli> arbitrary time, because the effect of that is unpredictable, even if
    Eli> the crash didn't happen.  I wanted to understand your thinking and
    Eli> rationale, so as to have a better basis for the decision of how to fix
    Eli> this problem.

    Eli> So could you please elaborate on your rationale?

Actually there is no deeper reason behind it.  I was just testing
threads in Emacs, seeing how things behave.  I certainly would think
twice before writing code that interrupts a thread at an arbitrary point
in a real program.

When it comes to sit-for, I use it sometimes.  Is there a reason not to
use it in threads?

In any case, I'm not encouraging anyone to program like that, I'm just
reporting a crash...

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#37892: 27.0.50; Crash when signaling a thread
  2019-10-23 17:06 bug#37892: 27.0.50; Crash when signaling a thread Michał Krzywkowski
  2019-10-25  8:44 ` Eli Zaretskii
@ 2021-12-05  3:15 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-05  3:15 UTC (permalink / raw)
  To: Michał Krzywkowski; +Cc: 37892

Michał Krzywkowski <mkrzywkow@gmail.com> writes:

> 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))

I can reproduce this in Emacs 27.1, but not in Emacs 28, so it seems
like this has been fixed, and I'm closing this bug report.  If the
problem is still present in Emacs 28, please respond to the debbugs
address and we'll reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-12-05  3:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-23 17:06 bug#37892: 27.0.50; Crash when signaling a thread Michał Krzywkowski
2019-10-25  8:44 ` Eli Zaretskii
2019-10-26 12:29   ` Michał Krzywkowski
2019-10-26 12:58     ` Eli Zaretskii
2019-10-27 10:16       ` Michał Krzywkowski
2019-10-27 13:25         ` Eli Zaretskii
2019-10-27 19:26           ` Michał Krzywkowski
2021-12-05  3:15 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).