Bug 76594 - regular expressions (re_comp) leak memory badly (breaks rdist and other programs)
Summary: regular expressions (re_comp) leak memory badly (breaks rdist and other progr...
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
(Show other bugs)
Version: 8.0
Hardware: i386 Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
Depends On:
TreeView+ depends on / blocked
Reported: 2002-10-23 21:31 UTC by John Heidemann
Modified: 2016-11-24 14:57 UTC (History)
3 users (show)

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

Attachments (Terms of Use)

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:

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*);

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

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.

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