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; }
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:31 MET