delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/05/05/10:15:05

Message-ID: <3AF40A31.B7EC98B7@jps.net>
From: Dennis Yelle <dennis51 AT jps DOT net>
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: new doesn't throw an exception
References: <3AF329A4 DOT 1B8469DE AT jps DOT net> <2950-Sat05May2001092233+0300-eliz AT is DOT elta DOT co DOT il>
Lines: 63
Date: Sat, 05 May 2001 07:12:01 -0700
NNTP-Posting-Host: 216.119.21.103
X-Complaints-To: abuse AT onemain DOT com
X-Trace: nntp2.onemain.com 989071710 216.119.21.103 (Sat, 05 May 2001 10:08:30 EDT)
NNTP-Posting-Date: Sat, 05 May 2001 10:08:30 EDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii wrote:
> 
> > From: Dennis Yelle <dennis51 AT jps DOT net>
> > Newsgroups: comp.os.msdos.djgpp
> > Date: Fri, 04 May 2001 15:13:57 -0700
> >
> > Call frame traceback EIPs:
> >   0x00013454 ___djgpp_traceback_exit+48
> >   0x00013536 _raise+94
> >   0x000128bb _abort+27
> >   0x0000d7eb ___default_terminate+11, line 0 of libgcc2.c
> >   0x0000e27d _terminate__Fv+13, line 0 of exception.cc
> >   0x0000e32a ___eh_alloc+30, line 0 of exception.cc
> >   0x0000d72d ___builtin_new+65, line 0 of new1.cc
> >   0x000015ca _main+42
> >   0x00010992 ___crt1_startup+178
> >
> > When new fails, it is supposed to throw an exception that
> > can be caught with
> >   catch(...)
> > But it does not do so.
> > Symify leads me to think that the problem is in new1.cc
> > I am trying to find the file new1.cc
> > It is NOT in DJLSR203.ZIP and it is not in GCC2953B.ZIP
> > Can anyone tell me where to find the source file new1.cc ?
> 
> It's probably in the sources of the libstdc++ library, which is part
> of gccNNNNs.zip distribution.  All the sources for C++ functions are
> there.

Thanks, you are right, it is in there.

It looks like a new handler got installed.
Probably by the startup code.
I am too tired right now to track it down.
This is contrary to the C++ standard, and
I think it should be fixed.

> > Also, it looks like new long usually allocates 24 bytes
> > per requested long.  This seems excessive to me.
> > Does anyone know why it should do this?
> 
> Some overhead for bookkeeping, perhaps.

New just calls malloc(), and malloc(4) acts the same way.
There is a bug in malloc for small allocations.
malloc() first rounds the size up to a multiple of 8 then
if it needs to call sbrk, it adds another 16 (instead of 8) to handle the
case that sbrk returns a noncontiguous chunk, if sbrk returns
a contiguous chunk, malloc does not reclaim the excess bytes.

I think this could be fixed by asking sbrk for a larger amount
in this case, at least 1000 bytes, and putting the excess
in the variable 'slop' which already exists.

It is pretty silly to ask sbrk for only 24 bytes each time, 
especially when we only really need 4 bytes.

Dennis Yelle
-- 
I am a computer programmer and I am looking for a job.
There is a link to my resume here:  
http://table.jps.net/~vert/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019