"HISTSIZE=999999999" cause bash failure after lastest upgrade

2016-09-25 Thread Sean Zha
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -Wdate-time 
-D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/bash-31ueiH/bash-4.4=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall 
-Wno-parentheses -Wno-format-security
uname output: Linux kali 4.6.0-kali1-amd64 #1 SMP Debian 4.6.4-1kali1 
(2016-07-21) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.4
Patch Level: 0
Release Status: release

Description:
I use a huge value for HISTSIZE (=9) to enable infinite
history items. The actural size of ~/.bash_history is only 4MB now.
Everything worked fine before the lastest upgrade. Now bash refuse
me to login due to memory allocation failure. After choosing
a smaller HISTSIZE, bash still eatup too much unnesssary memory.

Repeat-By:
open a workable terminal with small HISTSIZE setting,
$ echo HISTSIZE=9 > ~/test.rc
$ bash --rcfile ~/test.rc
  bash: xmalloc: cannot allocate 88 bytes (114688 bytes 
allocated)




Re: "HISTSIZE=999999999" cause bash failure after lastest upgrade

2016-10-08 Thread Sean Zha
It's fixed, thank you.

Sean


From: Chet Ramey 
Sent: Wednesday, October 5, 2016 9:16 PM
To: Sean Zha; bug-bash@gnu.org; b...@packages.debian.org
Cc: chet.ra...@case.edu
Subject: Re: "HISTSIZE=9" cause bash failure after lastest upgrade

On 9/25/16 6:59 PM, Chet Ramey wrote:
> On 9/25/16 3:51 PM, Sean Zha wrote:
>
>> Bash Version: 4.4
>> Patch Level: 0
>> Release Status: release
>>
>> Description:
>>   I use a huge value for HISTSIZE (=9) to enable infinite
>>   history items. The actural size of ~/.bash_history is only 4MB now.
>>   Everything worked fine before the lastest upgrade. Now bash refuse
>>   me to login due to memory allocation failure. After choosing
>>   a smaller HISTSIZE, bash still eatup too much unnesssary memory.
>>
>> Repeat-By:
>>   open a workable terminal with small HISTSIZE setting,
>>   $ echo HISTSIZE=9 > ~/test.rc
>>   $ bash --rcfile ~/test.rc
>> bash: xmalloc: cannot allocate 88 bytes (114688 bytes 
>> allocated)
>
> Since you've specified the desired history size, bash tries to allocate
> enough entries to hold all of the entries.  The assumption is that this
> will reduce the number of allocations/reallocations and the number of
> times the history list has to be copied as it's reallocated.  I suppose
> I should cap the maximum value for which that occurs instead of trusting
> the supplied max number of entries.

Try the attached patch and see whether or not it improves things.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/