Re: [ROOT] SegV in TTree::Fill when new objects occupy old addresses

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Nov 26 2002 - 15:42:07 MET


Hi Nick,

Your supposition is correct. In case of a TClonesArray, we assume that the
pointer does not change. If it does, you should call
   branch->SetAddress(&clones);
each time you recreate the TClonesArray.

Rene Brun

On Tue, 26 Nov 2002, Nick West wrote:

> Hi,
> 
> I have recently been getting a SegV filling a TTree with a single TBranch
> holding an object that has a data member that is a pointer to a
> TClonesArray.  For each fill a new object is created and subsequently
> deleted after filling. Looking with a debugger I could see that it was
> always writing the correct object but that sometimes it was using an out of
> date pointer to the TClonesArray.  Whenever this happened the new object had
> been created at the same address as the object that had that pointer.
> Perhaps the heap manager was refilling because it found a hole that exactly
> fitted the object.  So it occurs to me that there is logic in TTree:Fill
> that recognises an object by its address and saves time not traversing the
> object structure updating addresses in the TBranchElements that represent
> pointers to other objects.
> 
> So my questions are:-
> 
> 1)  Is this supposition correct:  i.e. save time by not updating addresses
> if the object address is unchanged?
> 2)  Is there a way to force the TTree to update addresses after recreating
> the objects it writes?
> 
> I am using 3.03/08 on Linux RedHat 6.1 (Cartman) with gcc 2.91.
> 
> Thanks,
> 
> Nick West
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:21 MET