Bug 120493 - Endless loop during demangling
Summary: Endless loop during demangling
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc
Version: 3.0
Hardware: ia64
OS: Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-04-09 12:07 UTC by Eugeny Klementev
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-05-12 03:40:24 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2004:142 0 normal SHIPPED_LIVE GCC bugfix update 2004-05-11 04:00:00 UTC

Description Eugeny Klementev 2004-04-09 12:07:44 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET 
CLR 1.1.4322)

Description of problem:
This example raise error:
----------------------
#include <string.h>

extern "C" char* __cxa_demangle (const char*  mangled_name, char* 
output_buffer, size_t* length, int* status);

int main () {
	char name [4096];
	char buf [4096];
	size_t n = 0;
	int status = 0;

	strcpy (name, "xFixDestroyDataBlock");
	__cxa_demangle (name, buf, &n, &status);
	return 0;
}
------------------------
There is endless loop in function __cxa_dyn_string_resize.
Source:
------------------------
dyn_string_t
dyn_string_resize (ds, space)
     dyn_string_t ds;
     int space;
{
  int new_allocated = ds->allocated;

  /* Increase SPACE to hold the NUL termination.  */
  ++space;

  /* Increase allocation by factors of two.  */
  while (space > new_allocated)
    new_allocated *= 2;
------------------------
The value os new_allocated is 0 and execution cannot be out of while 
loop.

Version-Release number of selected component (if applicable):
libstdc++-3.2-29

How reproducible:
Always

Steps to Reproduce:
1. Example from description


Additional info:

Comment 1 Jakub Jelinek 2004-04-14 12:49:30 UTC
Your testcase is flawed, buf if not NULL must be allocated by malloc
or realloc, see
http://www.codesourcery.com/cxx-abi/abi.html#demangler
But it loops even if the buffer is really malloced and there is another
bug in that it fails when status == NULL, which it should not.

Note that RHL 8.0 is no longer supported, so changing this to RHEL3.

Comment 2 Jakub Jelinek 2004-04-15 22:51:42 UTC
Please try
ftp://people.redhat.com/jakub/gcc/errata/3.2.3-34/

Comment 3 John Flanagan 2004-05-12 03:40:24 UTC
An errata has been issued which should help the problem described in this bug report. 
This report is therefore being closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files, please follow the link below. You may reopen 
this bug report if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2004-142.html



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