| Summary: | /bin/sh memory leak | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Bob Bishop <rb> |
| Component: | bin | Assignee: | tegge |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.3-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
Also affects -CURRENT -- Bob Bishop +44 (0)118 977 4017 rb@gid.co.uk fax +44 (0)118 989 4254 I resend the message because there is no my followup in gnats db. ---------- Forwarded message ---------- Date: Sat, 27 Oct 2001 20:11:25 +0400 (MSD) From: Maxim Konovalov <maxim@macomnet.ru> To: Bob Bishop <rb@gid.co.uk> Cc: freebsd-bugs@FreeBSD.ORG Subject: Re: bin/31533: /bin/sh memory leak On Sat, 27 Oct 2001, Bob Bishop wrote: > The following reply was made to PR bin/31533; it has been noted by GNATS. > > From: Bob Bishop <rb@gid.co.uk> > To: freebsd-gnats-submit@FreeBSD.org, rb@gid.co.uk > Cc: > Subject: Re: bin/31533: /bin/sh memory leak > Date: Sat, 27 Oct 2001 16:39:58 +0100 > > Also affects -CURRENT How about this patch: Index: cd.c =================================================================== RCS file: /home/ncvs/src/bin/sh/cd.c,v retrieving revision 1.20 diff -u -r1.20 cd.c --- cd.c 29 Nov 1999 19:10:58 -0000 1.20 +++ cd.c 27 Oct 2001 16:07:20 -0000 @@ -238,8 +238,8 @@ curdir = NULL; if (getpwd() == NULL) error("getcwd() failed: %s", strerror(errno)); - setvar("PWD", curdir, VEXPORT | VTEXTFIXED); - setvar("OLDPWD", prevdir, VEXPORT | VTEXTFIXED); + setvar("PWD", curdir, VEXPORT); + setvar("OLDPWD", prevdir, VEXPORT); INTON; return; } @@ -270,8 +270,8 @@ ckfree(prevdir); prevdir = curdir; curdir = savestr(stackblock()); - setvar("PWD", curdir, VEXPORT | VTEXTFIXED); - setvar("OLDPWD", prevdir, VEXPORT | VTEXTFIXED); + setvar("PWD", curdir, VEXPORT); + setvar("OLDPWD", prevdir, VEXPORT); INTON; } -- Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer phone: +7 (095) 796-9079, mailto: maxim@macomnet.ru [ My followup got lost as well. ] Maxim's patch appears to fix the problem. Someone please commit. -- Bob Bishop (0118) 977 4017 international code +44 118 rb@gid.co.uk fax (0118) 989 4254 Just as follow up. >From maxim@macomnet.ru Wed Nov 7 11:03:46 2001 Date: Mon, 5 Nov 2001 23:12:21 +0300 (MSK) From: Maxim Konovalov <maxim@macomnet.ru> To: Alfred Perlstein <bright@mu.org> Cc: Bob Bishop <rb@gid.co.uk>, hackers@FreeBSD.ORG Subject: Re: Committer please Hello, On Mon, 5 Nov 2001, Alfred Perlstein wrote: > * Bob Bishop <rb@gid.co.uk> [011105 06:35] wrote: > > Hi, > > > > Would some kind committer please have a look at bin/31533: /bin/sh memory > > leak. There is a patch there which I believe is OK. Having a memory leak > > loose in the shell seems like a Bad Idea to me. TIA > > Understandable, things like this could be applied more quickly if > someone would take the time to explain what the delta does other > than fix the problem. Meaning, what is VTEXTFIXED, and what does > removing it change? OK, mea culpa. /usr/src/bin/sh/var.h:48 #define VTEXTFIXED 0x08 /* text is staticly allocated */ Afaiu it is used for internal variables names which are statically allocated in /usr/src/bin/sh/var.c:102. VTEXTFIXED prevents them from freing: /usr/src/bin/sh/var.c:319 if ((vp->flags & (VTEXTFIXED|VSTACK)) == 0) ckfree(vp->text); PWD and OLDPWD variables are not statical ones and should be reallocated every time when changed. - -maxim -- Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer phone: +7 (095) 796-9079, mailto: maxim@macomnet.ru > PWD and OLDPWD variables are not statical ones and should be
> reallocated every time when changed.
I introduced this leak in revision 1.18 of cd.c while fixing a
different problem (cf. PR 2541). I've commited your suggested fix to
-current and will MFC it to RELENG_4 in a few days.
- Tor Egge
On Wed, 7 Nov 2001 Tor.Egge@cvsup.no.freebsd.org wrote: > > > PWD and OLDPWD variables are not statical ones and should be > > reallocated every time when changed. > > I introduced this leak in revision 1.18 of cd.c while fixing a > different problem (cf. PR 2541). I've commited your suggested fix to > -current and will MFC it to RELENG_4 in a few days. > > - Tor Egge Thank you! -- Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer phone: +7 (095) 796-9079, mailto: maxim@macomnet.ru Responsible Changed From-To: freebsd-bugs->tegge tegge introduced and fixed this bug. over to him to nag until MFC. State Changed From-To: open->closed Originator says this got MFC'd. Thanks. Hello, This PR can be closed. The fix was committed to -current and -stable. - -maxim -- Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer phone: +7 (095) 796-9079, mailto: maxim@macomnet.ru Hi, Maxim Konovalov <maxim@macomnet.ru> wrote: > This PR can be closed. The fix was committed to -current and -stable. I agree with that. -- Bob Bishop (0118) 977 4017 international code +44 118 rb@gid.co.uk fax (0118) 989 4254 |
/bin/sh leaks memory under certain conditions How-To-Repeat: Run the following (minimal) script, watch the shell with top(1): #!/bin/sh while true do cd /tmp while true do break done done