public inbox for glibc-bugs-regex@sourceware.org
help / color / mirror / Atom feed
* [Bug regex/1357] New: memory leak in re_compile_pattern()
@ 2005-09-19 21:24 root at liwave dot com
  2005-10-14  5:49 ` [Bug regex/1357] " drepper at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: root at liwave dot com @ 2005-09-19 21:24 UTC (permalink / raw)
  To: glibc-bugs-regex

Calling re_compile_pattern results in a memory leak proportional to the size of 
the Pattern String. See Example code below:
#include <regex.h>
#include <stdio.h>

int main()
{
	struct re_pattern_buffer	*patBuf;
	const char			*ErrStr;
	char				 PatStr[128];
	unsigned int			 i;
	


	patBuf = (struct re_pattern_buffer *) malloc(sizeof(struct 
re_pattern_buffer));
	if (!patBuf)
		exit(0);
	memset(patBuf, 0, sizeof(struct re_pattern_buffer));

	patBuf->translate      = 0;
	patBuf->fastmap	       = 0;
	patBuf->buffer	       = (char *) malloc(2048); //Optional
	patBuf->allocated      = 2048;
	patBuf->regs_allocated = REGS_UNALLOCATED; /Optional
	patBuf->used           = 0;

        re_set_syntax (RE_SYNTAX_POSIX_EGREP); //Optional
	for (i = 0; i < 10000; i++) {
		sprintf(PatStr, "TEST.?STRING%d", i); //This can be anything
                memset(patBuf->buffer, 0, 2048);
		ErrStr = re_compile_pattern(PatStr,
			                    strlen(PatStr),
					    patBuf);
		if (ErrStr)
		    printf("ErrStr = %s\n",ErrStr);
		} //endof for (i = 0; i < 10000; i++)
	if (patBuf->buffer)
		free(patBuf->buffer);
	if (patBuf)
		free(patBuf);
	
	exit(1);
	} //endof main()

Leak was introduced after glibc-2.2.2. This code works fine on a linux 2.4 
system running with glibc-2.2.2, leak occures in glibc 2.3.5 and 2.3.1 
glibc 2.3.5 was compiled with:
CFLAGS="-O3 -march=i686 -mcpu=i686 -funroll-loops -fomit-frame-pointer -
fexpensive-optimizations -pipe"

-- 
           Summary: memory leak in re_compile_pattern()
           Product: glibc
           Version: 2.3.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: regex
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: root at liwave dot com
                CC: glibc-bugs-regex at sources dot redhat dot com,glibc-
                    bugs at sources dot redhat dot com
  GCC host triplet: Linux gentoo 2.6.7-hardened-r18 #2 SMP Sun Jan 16
                    18:37:38 EST 2


http://sourceware.org/bugzilla/show_bug.cgi?id=1357

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug regex/1357] memory leak in re_compile_pattern()
  2005-09-19 21:24 [Bug regex/1357] New: memory leak in re_compile_pattern() root at liwave dot com
@ 2005-10-14  5:49 ` drepper at redhat dot com
  2005-12-30 20:52 ` drepper at redhat dot com
  2006-05-02 21:56 ` drepper at redhat dot com
  2 siblings, 0 replies; 6+ messages in thread
From: drepper at redhat dot com @ 2005-10-14  5:49 UTC (permalink / raw)
  To: glibc-bugs-regex


------- Additional Comments From drepper at redhat dot com  2005-10-14 05:49 -------
Yes, that interface doesn't work as before.  And it might remain broken.  It was
tied to the old implementation.

There might be a chance that the behavior is restored but I wouldn't hold my
breath.  Better rewrite your code to use the POSIX interfaces.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|gotom at debian dot or dot  |drepper at redhat dot com
                   |jp                          |
             Status|NEW                         |ASSIGNED


http://sourceware.org/bugzilla/show_bug.cgi?id=1357

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug regex/1357] memory leak in re_compile_pattern()
  2005-09-19 21:24 [Bug regex/1357] New: memory leak in re_compile_pattern() root at liwave dot com
  2005-10-14  5:49 ` [Bug regex/1357] " drepper at redhat dot com
@ 2005-12-30 20:52 ` drepper at redhat dot com
  2006-05-02 21:56 ` drepper at redhat dot com
  2 siblings, 0 replies; 6+ messages in thread
From: drepper at redhat dot com @ 2005-12-30 20:52 UTC (permalink / raw)
  To: glibc-bugs-regex



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   GCC host triplet|Linux gentoo 2.6.7-hardened-|Linux
                   |r18 #2 SMP Sun Jan 16       |
                   |18:37:38 EST 2              |


http://sourceware.org/bugzilla/show_bug.cgi?id=1357

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug regex/1357] memory leak in re_compile_pattern()
  2005-09-19 21:24 [Bug regex/1357] New: memory leak in re_compile_pattern() root at liwave dot com
  2005-10-14  5:49 ` [Bug regex/1357] " drepper at redhat dot com
  2005-12-30 20:52 ` drepper at redhat dot com
@ 2006-05-02 21:56 ` drepper at redhat dot com
  2 siblings, 0 replies; 6+ messages in thread
From: drepper at redhat dot com @ 2006-05-02 21:56 UTC (permalink / raw)
  To: glibc-bugs-regex


------- Additional Comments From drepper at redhat dot com  2006-05-02 21:56 -------
I meant to suspend this bug.  Nobody I know is going to work on this.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |SUSPENDED


http://sourceware.org/bugzilla/show_bug.cgi?id=1357

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug regex/1357] memory leak in re_compile_pattern()
       [not found] <bug-1357-132@http.sourceware.org/bugzilla/>
  2013-10-12 17:13 ` neleai at seznam dot cz
@ 2013-10-14 14:18 ` jsm28 at gcc dot gnu.org
  1 sibling, 0 replies; 6+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2013-10-14 14:18 UTC (permalink / raw)
  To: glibc-bugs-regex

https://sourceware.org/bugzilla/show_bug.cgi?id=1357

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |---

--- Comment #4 from Joseph Myers <jsm28 at gcc dot gnu.org> ---
I'm not sure what "will does not compile" means.  If you change "/Optional" to
"//Optional" then the code given here compiles with -D_GNU_SOURCE.  Maybe
there's something wrong with the code, but you need a clearer analysis if so
before closing the bug (and WONTFIX should only apply e.g. to a bug in a port
that's been removed; INVALID is what to do if the fault is in the user program
or the requested change is otherwise undesirable, just leave the bug open if
you're not interested in fixing it).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug regex/1357] memory leak in re_compile_pattern()
       [not found] <bug-1357-132@http.sourceware.org/bugzilla/>
@ 2013-10-12 17:13 ` neleai at seznam dot cz
  2013-10-14 14:18 ` jsm28 at gcc dot gnu.org
  1 sibling, 0 replies; 6+ messages in thread
From: neleai at seznam dot cz @ 2013-10-12 17:13 UTC (permalink / raw)
  To: glibc-bugs-regex

https://sourceware.org/bugzilla/show_bug.cgi?id=1357

Ondrej Bilka <neleai at seznam dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|SUSPENDED                   |RESOLVED
                 CC|                            |neleai at seznam dot cz
         Resolution|---                         |WONTFIX

--- Comment #3 from Ondrej Bilka <neleai at seznam dot cz> ---
Closing as mentioned interface will does not compile.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-10-14 14:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-19 21:24 [Bug regex/1357] New: memory leak in re_compile_pattern() root at liwave dot com
2005-10-14  5:49 ` [Bug regex/1357] " drepper at redhat dot com
2005-12-30 20:52 ` drepper at redhat dot com
2006-05-02 21:56 ` drepper at redhat dot com
     [not found] <bug-1357-132@http.sourceware.org/bugzilla/>
2013-10-12 17:13 ` neleai at seznam dot cz
2013-10-14 14:18 ` jsm28 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).