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:
Fixed in glibc-2.3.1-6 and later.