unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Andy Moreton <andrewjmoreton@gmail.com>,
	Fabrice Popineau <fabrice.popineau@gmail.com>
Cc: 22526@debbugs.gnu.org
Subject: bug#22526: 25.0.90; Crash starting gnus
Date: Fri, 12 Feb 2016 18:16:32 +0200	[thread overview]
Message-ID: <83fuwx7vkv.fsf@gnu.org> (raw)
In-Reply-To: <vz17fiayrv6.fsf@gmail.com> (message from Andy Moreton on Fri, 12 Feb 2016 13:34:37 +0000)

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Fri, 12 Feb 2016 13:34:37 +0000
> 
> I have managed to reproduce the crash again, and kept the gdb
> session running.

Thanks.  Now that you've succeeded, I'm going to ask you to terminate
the debug session and try applying a patch ;-)

> 411	  *(Z_ADDR) = 0;
> (gdb) p Z_ADDR
> $1 = (unsigned char *) 0x200804 <error: Cannot access memory at address 0x200804>
> (gdb) p *(Z_ADDR)
> Cannot access memory at address 0x200804
> 
> (gdb) p/x *(Z_ADDR - 0x804)
> Cannot access memory at address 0x200000
> (gdb) p/x *(Z_ADDR - 0x805)
> $16 = 0x0
> 
> (gdb) p/x (Z_ADDR - 0x805) - BEG_ADDR
> $18 = 0xffff

This means that, when enlarging buffer text, we failed to commit
memory beyond the initial 64KB, whereas the buffer was enlarged by
almost 4K beyond that.  This is unexpected (does your system exhibit
symptoms of memory pressure?), but the code which handles such a
possible failure to commit reserved pages is not safe in that case.
Please try the patch below, and see if these crashes go away.

Fabrice, can you read this thread and suggest other ideas for how
could this happen?  Do you think the patch below is TRT and should be
committed to the repository in any case?

diff --git a/src/w32heap.c b/src/w32heap.c
index 00da86a..f56d01b 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -700,6 +700,8 @@ mmap_realloc (void **var, size_t nbytes)
   /* We need to enlarge the block.  */
   if (memInfo.RegionSize < nbytes)
     {
+      void *old_ptr;
+
       if (VirtualQuery (*var + memInfo.RegionSize, &m2, sizeof(m2)) == 0)
         DebPrint (("mmap_realloc: VirtualQuery error = %ld\n",
 		   GetLastError ()));
@@ -717,7 +719,7 @@ mmap_realloc (void **var, size_t nbytes)
 	    {
 	      DebPrint (("realloc enlarge: VirtualAlloc error %ld\n",
 			 GetLastError ()));
-	      errno = ENOMEM;
+	      goto enlarge_block;
 	    }
 	  return *var;
 	}
@@ -726,7 +728,8 @@ mmap_realloc (void **var, size_t nbytes)
 	  /* Else we must actually enlarge the block by allocating a
 	     new one and copying previous contents from the old to the
 	     new one.  */
-	  void *old_ptr = *var;
+	enlarge_block:
+	  old_ptr = *var;
 
 	  if (mmap_alloc (var, nbytes))
 	    {





  reply	other threads:[~2016-02-12 16:16 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-01 22:13 bug#22526: 25.0.90; Crash starting gnus Andy Moreton
2016-02-07  5:42 ` Lars Ingebrigtsen
2016-02-07 16:00   ` Eli Zaretskii
2016-02-07 20:58     ` Andy Moreton
2016-02-07 21:05       ` Eli Zaretskii
2016-02-11  2:06         ` Andy Moreton
2016-02-11 20:27           ` Eli Zaretskii
2016-02-11 21:20             ` Andy Moreton
2016-02-11 21:26               ` Eli Zaretskii
2016-02-12 13:34                 ` Andy Moreton
2016-02-12 16:16                   ` Eli Zaretskii [this message]
2016-02-12 22:26                     ` Andy Moreton
2016-02-13  8:28                       ` Eli Zaretskii
2016-02-13 10:44                         ` Eli Zaretskii
2016-02-13 16:08                           ` Fabrice Popineau
2016-02-13 16:42                             ` Eli Zaretskii
2016-02-13 21:35                               ` Fabrice Popineau
2016-02-13 22:11                                 ` Eli Zaretskii
2016-02-13 23:44                                   ` Fabrice Popineau
2016-02-14  5:49                                     ` Eli Zaretskii
2016-02-14  9:05                                       ` Fabrice Popineau
2016-02-14 16:57                                         ` Eli Zaretskii
2016-02-14  5:41                                   ` Eli Zaretskii
2016-02-14 14:17                                     ` Andy Moreton
2016-02-14 16:55                                       ` Eli Zaretskii
2016-02-14 17:51                                         ` Eli Zaretskii
2016-02-14 21:04                                           ` Fabrice Popineau
2016-02-14 21:29                                             ` Eli Zaretskii
2016-02-14 21:31                                               ` Fabrice Popineau
2016-02-14 21:34                                             ` Eli Zaretskii
2016-02-14 21:41                                               ` Fabrice Popineau
2016-02-15  3:32                                                 ` Eli Zaretskii
2016-02-15  8:09                                                   ` Fabrice Popineau
2016-02-15 11:39                                                     ` Eli Zaretskii
2016-02-13 15:16                         ` Andy Moreton
2016-02-13 15:52                           ` Eli Zaretskii
2016-02-13 21:26                             ` Andy Moreton
2016-02-16  1:18                               ` Andy Moreton
2016-02-16  3:46                                 ` Eli Zaretskii
2016-02-20 11:08                                   ` Eli Zaretskii
2016-02-20 16:17                                     ` Andy Moreton
2016-02-20 17:01                                       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83fuwx7vkv.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=22526@debbugs.gnu.org \
    --cc=andrewjmoreton@gmail.com \
    --cc=fabrice.popineau@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).