[ROOT] RE: Make Class segmentation fault

From: Philippe Canal (pcanal@fnal.gov)
Date: Wed Aug 06 2003 - 21:38:53 MEST


Hi Christian,

I was not able to reproduce your problem.  However, there is a clear problem in the instruction you gave.  Some of the steps are in order:

  gmake
  produce a (potentially new TTessClass.h)
  execute runTestCut.run

and you have runTestCut.C which depends on TTestCut.C which depends on TTestClass.h
However you makefile does NOT reflect this dependency.  So even if we do thinks in 
the right order:

  produce a (potentially new TTessClass.h)
  gmake
	-> only TTestClass.o and runTestCut.run are recompiled
  execute runTestCut.run

we are using a TTestCut.o which uses the previous definition of TTestClass.h which is likely to cause memory problems, bad deletes and other random weird behaviors.

At a minimum the end of your Makefile should look like:

RUNTESTCUT_O    = runTestCut.o TTestCut.o TTestClass.o

all:	runTestCut.run 

runTestCut.o: runTestCut.C TTestClass.h  TTestCut.h

TTestClass.o: TTestClass.C TTestClass.h

TTestCut.o: TTestCut.C TTestCut.h  TTestClass.h


runTestCut.run:	$(RUNTESTCUT_O) 
	@echo "Building runTestCut.run ...."
	$(LD) $(LDFLAGS) $(RUNTESTCUT_O) $(ROOTLIBS) -o runTestCut.run

Cheers,
Philippe.


-----Original Message-----
From: Christian.Hansen@cern.ch [mailto:Christian.Hansen@cern.ch]
Sent: Wednesday, August 06, 2003 9:53 AM
To: root list; roottalk@pcroot.cern.ch
Subject: Make Class segmentation fault



Dear Rooters,

I get segmentation fault when I'm deleting a class
made from MakeClass. I've attached a tar ball of 
the directory where I have my test program that 
shows my problem. I do the following steps

* gmake 
* root 
  (open version 3.05/05)
* .x makeTestClass.cxx 
  (producing TTestClass.h and TTestClass.C)
* .q
* ./runTestCut.run

This runs runTestCut.C that calls TTestCut.C where
I do a loop over all entries in TTestClass and after
the run I delete the TTestClass. But this last step

	delete aTest;  (in runTestCut.C which calls)
	delete aTestClass;  (in TTestCut.C which calls)
	if (!fChain) return;
        delete fChain->GetCurrentFile(); (in TTestClass.h)

gives segmentation fault.
The strange thing is that if I comment out 'delete aTestClass'
in TTestCut.C the segmentation fault dissapears but if I instead
comment out the two rows in TTestClass.h the segmentation fault
does NOT dissapear. The output from the segmentation fault looks
like this:

*** Break *** segmentation violation
 Generating stack trace...
 0x401a44a4 in TUnixSystem::StackTrace() + 0x368 from 
/home/hansen/ROOT/lib/libCore.so
 0x401a306c in TUnixSystem::DispatchSignals(ESignals) + 0x78 from 
/home/hansen/ROOT/lib/libCore.so
 0x401a227f in <unknown> from /home/hansen/ROOT/lib/libCore.so
 0x401a5c7d in <unknown> from /home/hansen/ROOT/lib/libCore.so
 0x410cf7c8 in <unknown> from /lib/tls/libpthread.so.0
 0x41162983 in operator delete(void*) + 0x23 from /usr/lib/libstdc++.so.5
 0x400de6cf in TAttLine::~TAttLine [in-charge deleting]() + 0x27 from 
/home/hansen/ROOT/lib/libCore.so
 0x08049539 in TTestCut::~TTestCut [in-charge]() + 0xad from 
./runTestCut.run
 0x08048fed in main + 0x75 from ./runTestCut.run
 0x420156a4 in __libc_start_main + 0xe4 from /lib/tls/libc.so.6
 0x08048ee9 in TFile::TFile[in-charge](char const*, char const*, char 
const*, int) + 0x31 from ./runTestCut.run
Aborted


Are anyone of you able to reproduce this problem and if
then, would you know where I'm doing wrong using the class
produced from MakeClass?

With best regards
-- 
/ Christian Hansen
                                                                                
===============================================
Box 535            Office: +46-(0)18-471 32 57
S-751 21 Uppsala   Office: 82102
Sweden
-----------------------------------------------
Mobile    : +46-(0)708-887617
Home Page : http://welcome.to/Christian_Hansen
            http://cern.ch/Christian.Hansen



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET