Bug 76594

Summary: regular expressions (re_comp) leak memory badly (breaks rdist and other programs)
Product: [Retired] Red Hat Linux Reporter: John Heidemann <johnh>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Brian Brock <bbrock>
Severity: high Docs Contact:
Priority: medium    
Version: 8.0CC: dwmalone, fweimer, mitr
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-10-23 21:31:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description John Heidemann 2002-10-23 21:31:25 UTC
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 23:17:29 UTC
Fixed in glibc-2.3.1-6 and later.