Re: illegal instruction when quitting root

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Aug 27 1998 - 08:37:30 MEST


meb@gorby.dataventures.com wrote:
> 
> Dear Roottalk,
> 
> I have a user class (ItemMap) that is derived from the root class
> TNamed. I have one annoying problem that I can't fix. I have tried to
> follow the philosopy that 1) default contructors do not allocate
> memory, and 2) the destructor is protected in cases where only the
> default contructor was called. This hasn't helped.
> 
> Example: If I use an ItemMap stored in a root file, I can't quit root
> without causing a "*** Break *** illegal instruction" UNLESS I do
> either III.a or III.b below:
> 
> I.  open a rootfile with an ItemMap
> II. use the ItemMap
> III.
>     {
>         a. delete the ItemMap object in memory, or
>         b. close the rootfile
>     }
> IV. quit root
> 
> I think that it has something to do with TNamed (previously my ItemMap
> was derived from TObject). Any hints?
> 
> - Mike Beddo

>root [3] map->Dump()
>*fItemTable              ->205864d8  
>*fCategoryTable          ->20e7eca8  
>*fDirectory              ->204fcc78  !
>fName.*fData             ItemMap
>fTitle.*fData            BCF ItemMap

Hi Mike,
>From the map->Dump() info, I see that you have a pointer fDirectory.
My assumption is that you are probably inserting all the objects
in your map in the current directory/file in the objects constructors.
If this is the case, you must be careful that when you close the file
or delete the file/directory, the Root directory destructor
deletes all the objects inserted in the directory.
If you delete your objects before closing the directory, you
must also remove these objects from the directory (see for
example the TH1 constructors/destructor, otherwise your objects
will be deleted twice!
It is strongly recommended to insert in a directory only objects
created via the new operator to avoid the problem of objects
deleted when leaving the current scope, unless you protect
the object destructor for the fDirectory.
I suggest you add a simple print in your object destructors
to see what is happening.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:37 MET