From 88d69b7ddca305bb96d6e671300f6724e4f147dd Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 3 Oct 2012 22:52:49 -0700 Subject: [PATCH] * profiler.c (handle_profiler_signal): Inhibit pending signals too, to avoid similar races. * keyboard.c (pending_signals): Now bool, not int. --- src/ChangeLog | 6 ++++++ src/keyboard.c | 4 ++-- src/lisp.h | 2 +- src/profiler.c | 4 ++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ced0e057e2..744376b0ef 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2012-10-04 Paul Eggert + + * profiler.c (handle_profiler_signal): Inhibit pending signals too, + to avoid similar races. + * keyboard.c (pending_signals): Now bool, not int. + 2012-10-02 Paul Eggert * profiler.c (handle_profiler_signal): Fix a malloc race diff --git a/src/keyboard.c b/src/keyboard.c index 10dca010fb..19ece4a22f 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -76,9 +76,9 @@ along with GNU Emacs. If not, see . */ /* Positive if interrupt input is blocked right now. */ volatile int interrupt_input_blocked; -/* Nonzero means an input interrupt or alarm signal has arrived. +/* True means an input interrupt or alarm signal has arrived. The QUIT macro checks this. */ -volatile int pending_signals; +volatile bool pending_signals; #define KBD_BUFFER_SIZE 4096 diff --git a/src/lisp.h b/src/lisp.h index c3cabe0af2..2a647e593a 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2131,7 +2131,7 @@ extern char *stack_bottom; a request to exit Emacs when it is safe to do. */ extern void process_pending_signals (void); -extern int volatile pending_signals; +extern bool volatile pending_signals; extern void process_quit_flag (void); #define QUIT \ diff --git a/src/profiler.c b/src/profiler.c index 461aae3e09..51580710f2 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -239,6 +239,7 @@ handle_profiler_signal (int signal) else { Lisp_Object oquit; + bool saved_pending_signals; EMACS_INT count = 1; #ifdef HAVE_ITIMERSPEC if (profiler_timer_ok) @@ -252,12 +253,15 @@ handle_profiler_signal (int signal) uses QUIT, which can call malloc, which can cause disaster in a signal handler. So inhibit QUIT. */ oquit = Vinhibit_quit; + saved_pending_signals = pending_signals; Vinhibit_quit = Qt; + pending_signals = 0; eassert (HASH_TABLE_P (cpu_log)); record_backtrace (XHASH_TABLE (cpu_log), count); Vinhibit_quit = oquit; + pending_signals = saved_pending_signals; } } -- 2.39.2