Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Jun 2000 20:28:13 +0200
From:      Phil Pennock <pdp@nl.demon.net>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   misc/19406: setenv() allocates memory which is not freed by unsetenv()
Message-ID:  <E134Skv-0008h2-00@samhain.noc.nl.demon.net>

next in thread | raw e-mail | index | archive | help

>Number:         19406
>Category:       misc
>Synopsis:       setenv() allocates memory which is not freed by unsetenv()
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 20 11:30:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Phil Pennock
>Release:        FreeBSD 3.4-STABLE i386
>Organization:
n/a
>Environment:
Any
>Description:
setenv() allocates memory for variable.  unsetenv() does not free that memory.
>How-To-Repeat:
Compile the code below, run, find pid and use "ps up <pid>" to see the RSS
grow without apparent bound.

#include <stdlib.h>
#include <unistd.h>

#define Name "testing"
#define Value "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"

int
main (int argc, char *argv[])
{
	int i;

	while(1) {
		for (i=0; i<1000; ++i) {
			setenv(Name, Value, 1);
			unsetenv(Name);
		}
		sleep(1);
	}
	return 0;
}

>Fix:
Anyone want to think how many old programs depend on some buggy aspect of the
memory allocation involved here?

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E134Skv-0008h2-00>