delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/07/14:19:46

From: Michael Bukin <bukinm AT inp DOT nsk DOT su>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Emacs 22 env vars bug
Date: 05 Aug 1997 20:49:18 +0700
Organization: Budker Institute of Nuclear Physics
Lines: 50
Sender: mike AT Home-51 DOT inp DOT nsk DOT su
Message-ID: <m3k9i0buzl.fsf@H-Bukin.inp.nsk.su>
References: <Pine DOT SOL DOT 3 DOT 96 DOT 970715124917 DOT 6183A-100000 AT kruuna DOT Helsinki DOT FI>
<33d7e79d DOT 10682519 AT news-win DOT inp DOT nsk DOT su> <870780007 DOT 32194 AT dejanews DOT com>
NNTP-Posting-Host: h-bukin.inp.nsk.su
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Esa Peuha <Esa DOT Peuha AT helsinki DOT fi> writes:

> 
> In article <33d7e79d DOT 10682519 AT news-win DOT inp DOT nsk DOT su>,
>   bukinm AT inp DOT nsk DOT su wrote:
> > There is a bug in putenv (when allocating bigger chunk for
> > environ, one element is not counted).
> > This bug can explain magic number 21.
> 
> [patch snipped]
> 
> > The line with `putenv_bss_count = __bss_count;' was commented,
> > because later there is a test for `putenv_bss_count != __bss_count'.
> > (This can be left as it was, but it should be changed somehow).
> 
> Are you sure that this change won't cause another latent bug?

Code in question:

if ((putenv_bss_count != __bss_count) || (prev_environ != environ))
  {
    putenv_bss_count = __bss_count;
    ...
    if (putenv_bss_count != __bss_count)
      {
        prev_environ = environ;
        putenv_bss_count = __bss_count;
      }
  }

If first assignment in the block is deleted, then initial environ
will be free'd. And this can cause troubles if environ was not malloc'ed.

If left as is, there is no need in second if, values are always equal.

The question is, what to delete, `if' or assignment?
(Or, maybe, leave it alone? :)

> 
> > Emacs compiled with patched putenv does not crash,
> > but emacs compiled without it does.
> 
> The call to malloc your patch corrects is very likely the cause of this
> bug. Apparently it doesn't hurt djgpp's normal malloc routine, but Emacs'
> malloc seems to be more sensitive. If this is true, distributed emacs.exe
> should crash with 6, 22, 54, 118,... environment variables (ie power of 2
> minus 10). I'll test this ASAP.

  It may depend on the number of variables in djgpp.env.
Also, emacs adds SHELL=... (maybe only when SHELL is not defined).

- Raw text -


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