diff options
author | Eli Zaretskii <eliz@gnu.org> | 2017-10-04 10:27:49 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2017-10-04 10:27:49 +0300 |
commit | ea39d470bf35e45f1d8e39795f06ac74b3c37fc7 (patch) | |
tree | 406dbe320ffd5c9e2a31fd1b8568e119e50e9279 /src/thread.h | |
parent | fdbaebde08f4e53e3fc06fae99398c68a4e285fb (diff) | |
download | emacs-ea39d470bf35e45f1d8e39795f06ac74b3c37fc7.tar.gz emacs-ea39d470bf35e45f1d8e39795f06ac74b3c37fc7.tar.bz2 emacs-ea39d470bf35e45f1d8e39795f06ac74b3c37fc7.zip |
Avoid crashes on C-g when several threads wait for input
* src/thread.h (m_getcjmp): New member of 'struct thread_state'.
(getcjmp): Define to current thread's 'm_getcjmp'.
* src/thread.c (maybe_reacquire_global_lock): Switch to main
thread, since this is called from a SIGINT handler, which always
runs in the context of the main thread.
* src/lisp.h (sys_jmp_buf, sys_setjmp, sys_longjmp): Move the
definitions before thread.h is included, as thread.h now uses
sys_jmp_buf.
* src/keyboard.c (getcjmp): Remove declaration.
(read_char): Don't call maybe_reacquire_global_lock here.
(handle_interrupt): Call maybe_reacquire_global_lock here, if
invoked from the SIGINT handler, to make sure
quit_throw_to_read_char runs with main thread's Lisp bindings and
uses the main thread's jmp_buf buffer. (Bug#28630)
Diffstat (limited to 'src/thread.h')
-rw-r--r-- | src/thread.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/thread.h b/src/thread.h index 7fce8674f0e..cb2133d72d4 100644 --- a/src/thread.h +++ b/src/thread.h @@ -158,6 +158,13 @@ struct thread_state bool m_waiting_for_input; #define waiting_for_input (current_thread->m_waiting_for_input) + /* For longjmp to where kbd input is being done. This is per-thread + so that if more than one thread calls read_char, they don't + clobber each other's getcjmp, which will cause + quit_throw_to_read_char crash due to using a wrong stack. */ + sys_jmp_buf m_getcjmp; +#define getcjmp (current_thread->m_getcjmp) + /* The OS identifier for this thread. */ sys_thread_t thread_id; |