This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Static string template member crashes code


Michael Bletzinger wrote:
> 
> The tar zipped file produces an executable which crashes on a
> segmentation fault during an assignment to a static string member.  GDB
> shows that the string class is attempting to deallocate itself and
> failing because the char pointer "dat" is null.  I have had problems
> with this before in the old (gcc 2.7.2) string class. The problem
> cropped up intermittently when strings were being returned in functions
> or used as static members.  I think we need some kind of low level check
> for the char pointer right before we delete the array.  I am going to
> try to fix this so let me know if you already have something in the
> works.
> 
> The environment:
> SunOS ultra2a 5.6 Generic sun4u sparc SUNW,Ultra-2
> egcs version 1.1.1
> 
>         Thanks
>         Michael
> --
> First Rule of Engineering Design:
> It is wiser to present an unworkable design rather
> than a workable design to speed up the revision process
> Phone (voice): (812)854-1101    (fax):   (812)854-3437
> 
>   ------------------------------------------------------------------------
>                       Name: StringCrash.tgz
>    StringCrash.tgz    Type: unspecified type (application/octet-stream)
>                   Encoding: base64

I found another case where an instantiated map which is also a static
member of a template also crashed because of null pointers.  This time
the pointer "header" was zero.  Is it possible that if you have an
instantiated template declared as a static member of a template, that
the member is not being properly initialized?  Am I perhaps not
following the standard rules for using templates?  I also noticed that
GDB did not recoginize a static breakpoint where these members were
declared but I figured this was because GDB did not know which
instatiation to tag for breaking.

I have a work around where I declare these members as static pointers
and dynamicly allocate them in the constructor, but I would like to fix
this if a can.  Especially if this can be fixed in the STL.

	Any hints would be appreciated
	Thanks
	Michael 
-- 
First Rule of Engineering Design:
It is wiser to present an unworkable design rather
than a workable design to speed up the revision process
Phone (voice): (812)854-1101    (fax):   (812)854-3437


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]