www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/17/03:40:38

Date: Thu, 17 Jul 1997 10:40:04 +0300 (EET DST)
From: Esa A E Peuha <peuha AT cc DOT helsinki DOT fi>
Reply-To: Esa DOT Peuha AT Helsinki DOT FI
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
cc: djgpp AT delorie DOT com
Subject: Bug in `putenv'/`crt1'? (was Re: Emacs 22 env vars bug)
In-Reply-To: <Pine.SOL.3.96.970715124917.6183A-100000@kruuna.Helsinki.FI>
Message-ID: <Pine.SOL.3.96.970717103121.8542A-100000@kruuna.Helsinki.FI>
MIME-Version: 1.0

On Tue, 15 Jul 1997, Esa A E Peuha wrote:

> It's possible that `regex_compile' calls `realloc' with invalid pointer;
> if so, the fault is an uninitialized pointer in `search.c'. I'll change
> `_free_internal' to recognize this, and will post the patch for testing.

After all, there's probably nothing wrong with `search.c'. Here's a patch
that will cause `_free_internal' to crash if it is called with invalid
pointer (useful for debugging, but normally this should probably just
return):

*** src\gmalloc.c	Tue Aug 13 01:12:20 1996
--- newsrc\gmalloc.c	Tue Jul 15 15:18:22 1997
***************
*** 907,919 ****
--- 907,924 ----
    if (ptr == NULL)
      return;
  
+   curbrk = NULL;
    for (l = _aligned_blocks; l != NULL; l = l->next)
      if (l->aligned == ptr)
        {
  	l->aligned = NULL;	/* Mark the slot in the list as free.  */
  	ptr = l->exact;
+ 	curbrk = ptr;
  	break;
        }
+ 
+   if (curbrk == NULL)
+     ptr = *(__ptr_t *) curbrk;	  /* Crash if invalid pointer.  */
  
    block = BLOCK (ptr);

----- end of patch -----  

With this patch, even my emacs.exe will crash, and the traceback points to
`putenv'. Is this a bug in `putenv.c' or `crt1.c' or both, or is it
something specific to Emacs?

Esa Peuha
student of mathematics at the University of Helsinki
http://www.helsinki.fi/~peuha/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019