Bug 76594 - regular expressions (re_comp) leak memory badly (breaks rdist and other programs)
regular expressions (re_comp) leak memory badly (breaks rdist and other progr...
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
8.0
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-10-23 17:31 EDT by John Heidemann
Modified: 2016-11-24 09:57 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-10-23 17:31:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description John Heidemann 2002-10-23 17:31:25 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2b) Gecko/20021017

Description of problem:
re_comp leaks memory badly
(about 500KB each call, 100k calls leaks about 50MB)
This makes programs like rdist (and others that use glibc's regular expressions)
exceed VM size quickly.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. complile and run this program:



	#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <regex.h>
#include <assert.h>

extern char *re_comp(char*);

int
main(int argc, char **argv)
{
	int n = 100000;
	char *re = "xxx";
	char *target = "yyy";
	char *re_comp_res;
	int re_matches;

	while (n-- > 0) {
		re_comp_res = re_comp(re);
		assert(re_comp_res == NULL);
		/* leaks memory even without calling re_exec */
		/* re_matches = re_exec(target); */
	};

	printf("done with %d iterations.\n", n);
	for (;;)
		;
	/* memory usage is 50MB under RH8 vs. 384KB under RH 7.3 */
}


Actual Results:  memory usage (in the infinite loop) is 50MB under RH8
(glibc-2.2.93-5)


Expected Results:  memory usage was only 384KB under RH7 (glibc-2.2.5-40)

Additional info:
Comment 1 Jakub Jelinek 2002-12-03 18:17:29 EST
Fixed in glibc-2.3.1-6 and later.

Note You need to log in before you can comment on or make changes to this bug.