emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r105340: * alloc.c (memory_full) [!SY


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105340: * alloc.c (memory_full) [!SYNC_INPUT]: Fix signal-related race.
Date: Thu, 28 Jul 2011 10:05:33 -0700
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105340
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Thu 2011-07-28 10:05:33 -0700
message:
  * alloc.c (memory_full) [!SYNC_INPUT]: Fix signal-related race.
  
  Without this fix, if a signal arrives just after memory fills up,
  'malloc' might be invoked reentrantly.
modified:
  src/ChangeLog
  src/alloc.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-07-28 09:40:05 +0000
+++ b/src/ChangeLog     2011-07-28 17:05:33 +0000
@@ -1,5 +1,9 @@
 2011-07-28  Paul Eggert  <address@hidden>
 
+       * alloc.c (memory_full) [!SYNC_INPUT]: Fix signal-related race.
+       Without this fix, if a signal arrives just after memory fills up,
+       'malloc' might be invoked reentrantly.
+
        * image.c (x_check_image_size) [!HAVE_X_WINDOWS]: Return 1.
        In other words, assume that every image size is allowed, on non-X
        hosts.  This assumption is probably wrong, but it lets Emacs compile.

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2011-07-19 20:33:28 +0000
+++ b/src/alloc.c       2011-07-28 17:05:33 +0000
@@ -3282,12 +3282,16 @@
   int enough_free_memory = 0;
   if (SPARE_MEMORY < nbytes)
     {
-      void *p = malloc (SPARE_MEMORY);
+      void *p;
+
+      MALLOC_BLOCK_INPUT;
+      p = malloc (SPARE_MEMORY);
       if (p)
        {
          free (p);
          enough_free_memory = 1;
        }
+      MALLOC_UNBLOCK_INPUT;
     }
 
   if (! enough_free_memory)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]