From a3c5c0c5800ca55a2b0548d3d30a39f570b10e90 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 2 Oct 2012 12:38:10 -0700 Subject: [PATCH] * profiler.c (handle_profiler_signal): Fix a malloc race that caused Emacs to hang on Fedora 17 when profiling Lisp. --- src/ChangeLog | 5 +++++ src/profiler.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index e905a800f70..ced0e057e27 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2012-10-02 Paul Eggert + + * profiler.c (handle_profiler_signal): Fix a malloc race + that caused Emacs to hang on Fedora 17 when profiling Lisp. + 2012-10-02 Jan Djärv * nsterm.m (windowDidEnterFullScreen): Remove fprintf. diff --git a/src/profiler.c b/src/profiler.c index 3282b8b335b..7b4ffc7f7bf 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -238,6 +238,7 @@ handle_profiler_signal (int signal) cpu_gc_count = saturated_add (cpu_gc_count, 1); else { + Lisp_Object oquit; EMACS_INT count = 1; #ifdef HAVE_TIMER_SETTIME if (profiler_timer_ok) @@ -247,8 +248,16 @@ handle_profiler_signal (int signal) count += overruns; } #endif + /* record_backtrace uses hash functions that call Fequal, which + uses QUIT, which can call malloc, which can cause disaster in + a signal handler. So inhibit QUIT. */ + oquit = Vinhibit_quit; + Vinhibit_quit = Qt; + eassert (HASH_TABLE_P (cpu_log)); record_backtrace (XHASH_TABLE (cpu_log), count); + + Vinhibit_quit = oquit; } } -- 2.39.5