bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory leak in subshell + read before bash 4.4


From: Chet Ramey
Subject: Re: Memory leak in subshell + read before bash 4.4
Date: Fri, 3 Nov 2017 21:21:09 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 11/3/17 9:18 PM, Adrien Mahieux wrote:
> On Sat, Nov 4, 2017 at 1:18 AM, Chet Ramey <address@hidden> wrote:
>> On 11/3/17 6:01 PM, Adrien Mahieux wrote:
>>> Hello,
>>>
>>> I think I've found a bug in the loop management. Maybe it's an
>>> expected behavior (didn't find any related topic on the manpages) but
>>> it's annoying in long-running scripts.
>>>
>>> The leak is triggered by this idiom (wether or not jobcontrol + lastpipe) :
>>> cmd | read var
>>>
>>> but not by this one :
>>> read var < <(cmd)
>>>
>>> Tested with :
>>> - bash-4.2.46-19.el7.x86_64
>>> - bash-4.3.42-5.fc23.x86_64
>>> - bash-4.3-48.x86_64
>>>
>>> From the version tested, it was fixed in version 4.4 (tested 4.4-beta)
>>> Do you have an idea of the commit that fixed this behavior, so the fix
>>> can be backported to older versions ?
>>
>> Have you tried bisecting the devel git branch?
> 
> Didn't have time, nor tried. That's my first bisect \o/
> 
> 85ec0778f9d778e1820fb8c0e3e996f2d1103b45 : no leak
> 1a088fee7368a8620e0bf64c481ac0bc5dddddcf : leak
> 
> 
> This modification from 85ec0778 did fix the leak in 1a088fee73 :
> 
> -  if ((dflags & DEL_NOBGPID) == 0)
> +  if ((dflags & DEL_NOBGPID) == 0 && (temp->flags &
> (J_ASYNC|J_FOREGROUND)) == J_ASYNC)
> 
> 
> Can you check and backport it ?

If it's that, it's not a leak. It's bash-4.3 keeping exit statuses for the
last CHILD_MAX processes.  Bash-4.4 restricts that to the last CHILD_MAX
asynchronous background processes, with accompanying loss of functionality.

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]