RE: [ROOT] ther IS !!! a bug in TArrayD !!

From: Axel Naumann (a.naumann@worldnet.att.net)
Date: Sun Oct 07 2001 - 17:34:43 MEST


Dear Joe and other Windows user,

I've seen the same strange behaviour, and it took me a while (and some help)
to figure out by what it's caused. First a guess: It only happens when you
execute your code in debug mode, right? Now, here's the explanation:

Root has its own delete and new operators. The problem is that root is
linked against the release version of the new/delete operators, whereas YOUR
code (compiled in debug mode) links against the debug version of these
operators, which embeds the allocated memory in some debug fields (and
checks its concistency when delete is called). The problem is harmless, and
only appears in the combination of new/deletes with your and root's code.

So the two versions are incompatible. What you should do is link your code
against the release version of the libraries (although this means you won't
find memory problems caused by your code). You can set the version MSVC
links against in project settings, tab C/C++, entry "code generation", use
run-time library "single threaded" instead of "debug single threaded".

This should fix your problem. As a clarification: This is NOT a root
problem, it's a problem of mixing different operator versions (and maybe of
MSVC not being able to select the correct one). I've no clue how to prevent
this problem in a more general way.

Cheers, Axel.

> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Valeri Fine
> Sent: Saturday, October 06, 2001 6:35 PM
> To: joe robe; roottalk@pcroot.cern.ch
> Subject: Re: [ROOT] ther IS !!! a bug in TArrayD !!
>
>
> Dear Joe a few days ago I asked you to change your code slightly.
> By some reason I had no E-mail access for the last several days.
> Have you implemented the corrections I was speaking about ?
> Didn't it help  ?
>
> I've to remind that ROOT under Window is implemented as a  multithread
> program.
> On other hand some pieces of ROOT are not thread safe.
> This means one always can write the code that will access one and the same
> memory
> simultaneously and cause the program crash.
>
> When you create your own "root-based" application you have to take this in
> account
> to keep your application thread-safe to avoid an unexpected crashes.
>
> Very likely I should explain briefly that the interactive
> applications like
> ROOT has to be multithreaded.
> Under UNIX there is no need for any special pre-caution since the second
> "interactive" thread is resided
> within a separate process (called "X-terminal"). By this reason the
> interactive X-based application may be single-thread. Windows OS doesn't
> provide a dedicated separate "process-terminal" to manage "widgets".
> WIN32 application must control its own widget alone. By this
> reason the ROOT
> (and any other application) under Windows has to create and maintain such
> kind of "control" thread internally.
> ( See:  http://root.cern.ch/root/roottalk/roottalk01/3432.html thread )
>
> By this reason I'd like to ask you again to try applying the
> remedy I posted
> a few days ago
> and tell us whether it helps.
>
> With my bet regards, Valeri
>
> ----- Original Message -----
> From: "joe robe" <joer00@yahoo.com>
> To: <roottalk@pcroot.cern.ch>
> Sent: Saturday, October 06, 2001 5:40 PM
> Subject: [ROOT] ther IS !!! a bug in TArrayD !!
>
>
> > once again I have trouble in my program and tracked it
> > down to TArrayD.
> >
> > In debug mode there where some strange brekapoints
> > called, although I havent set any ! I looked into the
> > groups and w2k and nt are setting some check bytes on
> > each allocated block and verify if something changed
> > when releasing it. if so (memory overridden) debug
> > breakpoint is called.
> >
> > So this line calls this breakpoint which fits
> > perfectly into my observation that TArrayD is LEAKING
> > !
> >
> > TArrayD* Test=new TArrayD(100);
> > delete Test;
> >
> > Joe
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > NEW from Yahoo! GeoCities - quick and easy web site hosting, just
> $8.95/month.
> > http://geocities.yahoo.com/ps/info1
> >
>
>



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:02 MET