Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14932

Re: Memory continusely increase

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From chen liu <chen.liu.opensource@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Memory continusely increase
Date Thu, 20 Dec 2018 11:31:36 +0800
Lines 105
Approved bug-bash@gnu.org
Message-ID <mailman.5986.1545277064.1284.bug-bash@gnu.org> (permalink)
References <1545199834453-0.post@n7.nabble.com> <CAOSMAuty6ac28_1by44fnjPFFkH8_9Sn3qz7K3tQBdWd0kWwDQ@mail.gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1545277065 18968 208.118.235.17 (20 Dec 2018 03:37:45 GMT)
X-Complaints-To action@cs.stanford.edu
Cc abhishpaliwal@gmail.com, bug-bash <Bug-bash@gnu.org>
To Eduardo Bustamante <dualbus@gmail.com>
Envelope-to Bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=6nE8sRyU789taTuwMkSxJ86F5gM7gcc1DxoOt/TtDnI=; b=rNVtTlRaq8uICIdjN9A1kbNipdRH8wX9eFcd1QC1gGAuPFBAO/c+zlIMwfeQZLHQwh Emb3FA3R0nOr4GnnEAssyZNDYQmHwYOcAiV8ezgnVFzBddjMPMDh32Wjf0qGZuLeh/4o ez6FXJ7zDoaq11ytxlFAkuED4Kq5SHh6sTzigcOWiLspL8JZe6nOQY/ujox4ZgA/rh4V +R4M5sbfej9H7YPXto3vcv4aquzOwzlloqmuFuinrxE1HkGu9dVQ8ZRd5J4R+soaGBFD EorVISQbBzonZL4TqHf18cWUtX+aUaSqfJFxXaqbxSQS8LOnVOiTjBBXew2GSCf2S4K5 VlOQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6nE8sRyU789taTuwMkSxJ86F5gM7gcc1DxoOt/TtDnI=; b=XKphjORg6VzXGIQDGq5ps9PClbSQIN6GffeDTDj/+Xm40hSB9hEkGPj4oQHyzEfr1M 6sKBDeGzucL20HJhutywCiDL/NwrvGcmjTBgcC0UiViOisi7F6TKjli3Mt8fn2HAAK1b qo1qM4601hhQwNEw7KEppIFe+2Rke5j1mFdqCoTekiYClHCjLPnRDMuJxysBwVmkdW4z zxVsU1q5qSqGCFvOl4RHoKl1yuuCRoOWb1dcyny+0LXisaWjg4HHNKcdVSYvOhwyfYyi 4JF+m4Xu5Bx+EbsH5cXz8cownmEhUVP5Kwx51hvuYGqxG8vTL/AmQyENjWTTIsZF6HpO 4VYg==
X-Gm-Message-State AA+aEWZX0JTlKdjPFNSWN5WvoVo2DjU3R+S7Es3NkYRzD6CUK0SYNOF9 8i20BAb7Vfjvpl4/erFTJ2lItzErmChoH9CPgck=
X-Google-Smtp-Source AFSGD/VTLEWvNhzfmymcAcXaGfbgpWKPaUAJgMgTNSA7oRf23E4N55CiVNRGWEAlp8bijuzNzqx8GMWtpkClc3s5QyI=
X-Received by 2002:a67:105:: with SMTP id 5mr11208949vsb.183.1545277060850; Wed, 19 Dec 2018 19:37:40 -0800 (PST)
In-Reply-To <CAOSMAuty6ac28_1by44fnjPFFkH8_9Sn3qz7K3tQBdWd0kWwDQ@mail.gmail.com>
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2607:f8b0:4864:20::e34
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14932

Show key headers only | View raw


Eduardo Bustamante <dualbus@gmail.com> 于2018年12月20日周四 上午1:58写道:
>
> + Adding Abhishek

> On Wed, Dec 19, 2018 at 6:45 AM jake <chen.liu.opensource@gmail.com> wrote:
> >
> > Hi all,
> >
> > I did a test about run a bash scriplt never quit,but met a memory usage
> > issue that cause used memory continuous increase.
> > This issue was present in bash-3.2.x, bash-4.0.x, bash-4.1.x, bash-4.2.x,
> > bash-4.3.x. However, This issue was disappeared in bash-4.4.0, I can't trace
> > which patch fixed the issue or which new feature was introduced in
> > bash-4.4.0.
>
> These versions (3.2, 4.0, 4.1, 4.2 and 4.3) are fairly old. Any
> particular reason you're not upgrading to 4.4 instead?

It has deployed to our devices, so if direct upgrade to bash-4.4, we
need spend about
one year to verify it.

>
> > Could someone help to tell me which part of changes in bash-4.4.0, that
> > would be give me a direction backport code changes from bash-4.4 to
> > bash-3.2.x and bash-4.3.x.
>
> (...)
>
> > while(true);do
> >  while (true); do
> >    ls > /dev/null
> >  done
> > done
>
> My guess is that it's a memory leak in subshell creation. You don't
> need that subshell by the way, the following should work just fine:
>
> while :; do
>  ...
> done
>
> The parenthesis are not only not needed, but they add overhead because
> a new subshell is created every time.

This issue still present even remove the parenthesis.
As you said, the memory leak in subshell creation. The subshell create
in every loop and
that scirpt is infinite loop that would be cause create many Child
processes, maybe there
have some resource don't be release when the child process has exited.

below is the calling process:
________________________________________

execute_command_internal() (loop-start)
              |
execute_in_subshell()
              |
execute_command_internal()
              |
execute_simple_command()
              |
execute_command_internal()
              |
execute_simple_command()
              |_________(loop-start)
__________________________________


> Anyways, looking at the changelog for 4.4, it looks like it's going to
> be time consuming to find / backport this, since there are many memory
> leaks that were fixed:
>
> $ grep -i leak ./CHANGES-4.4
> c.  Fixed several memory leaks.
> a.  Fixed a memory leak when processing ${!var[@]}.
> i.  Fixed a memory leak in the code that removes duplicate history entries.
> b.  Fixed a memory leak in programmable completion.
> i.  Fixed a memory leak when processing declare commands that perform compound
> s.  Fixed a memory leak that occurred when interrupting brace expansions
> dd. Fixed a memory leak when creating local array variables and assigning to
> p.  Fixed a potential file descriptor leak when dup2() fails while performing a
> i.  Some memory leaks caused by signals interrupting filename completion have
>
>
> I'll try to go through some of these changes later today to see if
> anything evident comes up. I still recommend just upgrading to 4.4 if
> you can though. Running outdated versions is never fun.

Thanks for your efforts:)

Thanks,
Chen.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Memory continusely increase chen liu <chen.liu.opensource@gmail.com> - 2018-12-20 11:31 +0800

csiph-web