diff options
| author | Eli Zaretskii | 2016-01-11 18:05:40 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-01-11 18:05:40 +0200 |
| commit | 36b953947ee2ee0411139bd4ad7dcffdcc403036 (patch) | |
| tree | e2bbd90e8712a1d9f7f011805ca35a5c92cb447b /src | |
| parent | 200675299e24139ccce444a7ca5d59a2aed2891c (diff) | |
| download | emacs-36b953947ee2ee0411139bd4ad7dcffdcc403036.tar.gz emacs-36b953947ee2ee0411139bd4ad7dcffdcc403036.zip | |
Avoid an infloop when we run out of memory
* src/alloc.c (garbage_collect_1): Don't bother saving and
restoring the echo-area message if we are GC'ing after running out
of memory. This avoids an infloop due to repeated attempts to
allocate memory for the cons cell needed to save the message,
which signals the memory-full error, which attempts to save the
echo-area message, which signals memory-full again, etc.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/alloc.c b/src/alloc.c index 8ceacfe8ead..03dacc77c6e 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -5525,9 +5525,16 @@ garbage_collect_1 (void *end) | |||
| 5525 | don't let that cause a recursive GC. */ | 5525 | don't let that cause a recursive GC. */ |
| 5526 | consing_since_gc = 0; | 5526 | consing_since_gc = 0; |
| 5527 | 5527 | ||
| 5528 | /* Save what's currently displayed in the echo area. */ | 5528 | /* Save what's currently displayed in the echo area. Don't do that |
| 5529 | message_p = push_message (); | 5529 | if we are GC'ing because we've run out of memory, since |
| 5530 | record_unwind_protect_void (pop_message_unwind); | 5530 | push_message will cons, and we might have no memory for that. */ |
| 5531 | if (NILP (Vmemory_full)) | ||
| 5532 | { | ||
| 5533 | message_p = push_message (); | ||
| 5534 | record_unwind_protect_void (pop_message_unwind); | ||
| 5535 | } | ||
| 5536 | else | ||
| 5537 | message_p = false; | ||
| 5531 | 5538 | ||
| 5532 | /* Save a copy of the contents of the stack, for debugging. */ | 5539 | /* Save a copy of the contents of the stack, for debugging. */ |
| 5533 | #if MAX_SAVE_STACK > 0 | 5540 | #if MAX_SAVE_STACK > 0 |
| @@ -5658,7 +5665,7 @@ garbage_collect_1 (void *end) | |||
| 5658 | } | 5665 | } |
| 5659 | } | 5666 | } |
| 5660 | 5667 | ||
| 5661 | if (garbage_collection_messages) | 5668 | if (garbage_collection_messages && NILP (Vmemory_full)) |
| 5662 | { | 5669 | { |
| 5663 | if (message_p || minibuf_level > 0) | 5670 | if (message_p || minibuf_level > 0) |
| 5664 | restore_message (); | 5671 | restore_message (); |