Re: [ROOT] Running without libNew/ default initialization

From: Tim Welters (welters@physik.rwth-aachen.de)
Date: Sat Aug 19 2000 - 16:56:42 MEST


Hello George,

I don't know the official position about running without libNew, but
I can say that all seems to work fine without libNew.
We are working on alpha architectures under OSF1 and there the libNew
regularly causes severe exceptions (e.g. starting the root environment
crashes during reading the .rootrc file). So we use root completely
without libNew (for root-config there is even a switch called "--nonew").
Until know there we did not have problems without libNew.

Tim

George Heintzelman wrote:
> 
> Rooters,
> 
> I was just wondering what the 'official' position was on running
> without libNew. Is this mode officially supported? Since they are
> separate libraries, it is obviously very easy to omit libNew and either
> use the default system on or put in your own.
> 
> The reason I ask this is that the way libNew works makes it very easy
> to write wrong code which will fail drastically without it. LibNew
> initializes all of the memory space allocated inside it to 0; and that
> means that people assume that pointer (and other) members in a TObject
> default to 0 (laying aside the issue of the rare compiler that does not
> use all-bits-0 for the null pointer). They do not, of course, in
> ordinary C++ code; they are left unintialized, meaning random garbage,
> unless you initialize them. This is true even on the stack, of course,
> but since the ROOT idiom seems to be strongly slanted towards heap
> allocation*, many users never see the errors that could crop up from
> failure to correctly initialize on the stack.
> 
> Now, I am trying to run root and our local root-derived libraries under
> Insure++, a leak/memory misuse detection system that doesn't interact
> very well with libNew (and takes on libNew's functionality and more, so
> there's no point in keeping it around). But because libNew's convenient
> zeroing of members is now gone, I get to deal with all the
> non-initialized problems which people should have seen long ago and
> fixed, even before getting to use the tool to find the real problems
> I'm looking for.
> 
> Since the global operator new doesn't get called for static allocation,
> this also provides a very nasty surprise for people who think that code
> has been well-tested -- until someone tries to use one of their object
> on the stack.
> 
> So I guess I am suggesting that the zero-ing out provided in libNew is
> more of a curse than a blessing, in the long run, and ought to be
> removed in favor of making (er, helping to encourage) people write
> their constructors correctly the first time.
> 
> George Heintzelman
> gah@bnl.gov
> 
> *It's so strongly slanted that I've seen people (who have never seen
> C++ outside of Root) write code like this, I kid you not. Don't even
> ask about using contained data members instead of pointers:
> 
> void function() {
> TSomeObject *x = new TSomeObject();
> // Do some processing
> // ..
> // ..
> 
> delete x;
> }

-- 
------------------------------------------------------------------------
Tim Welters, III.Physikalisches Institut at the RWTH Aachen, Lehrstuhl B 
Room: H.116         Tel.: +49(241)80-6355          Fax: +49(241)8888-244
Postal Address:   Physikzentrum, RWTH Aachen, D-52056 Aachen
e-mail: welters@physik.rwth-aachen.de      or        Tim.Welters@cern.ch
------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:31 MET