]> code.delx.au - gnu-emacs/commitdiff
* profiler.c (handle_profiler_signal): Fix a malloc race
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 2 Oct 2012 19:38:10 +0000 (12:38 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 2 Oct 2012 19:38:10 +0000 (12:38 -0700)
that caused Emacs to hang on Fedora 17 when profiling Lisp.

src/ChangeLog
src/profiler.c

index e905a800f700ad7e7f29790cc85769a248a9cd12..ced0e057e2766568f4caf1a257c1fe5f77db96dc 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-02  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * 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  <jan.h.d@swipnet.se>
 
        * nsterm.m (windowDidEnterFullScreen): Remove fprintf.
index 3282b8b335bb546d96c7ab50d1ec466133d60f7b..7b4ffc7f7bf2f9de46510f93ad74ef4ddd021099 100644 (file)
@@ -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;
     }
 }