Macro crashing

Hi all,
I have a root macro that keeps crashing; it crashes in different places every time I run it.
The macro is in attachment.Briefly: I have 21 TFiles, each of them containing a TTree
and a TString. Each TTree corresponds to a ‘Run’ in which a parameter (not saved) was changed.
So I want to plot some information from the tree as a function of the external parameter.
This is the printout:

Warning in <TH1::Build>: Replacing existing histogram: Adc;Run0;Ch21 (Potential memory leak).
Prjocetion has been done!
Adc;Run0;Ch22
hAdc has been initialized!
Col == 2 && Row == 6
hname: Adc;Run0;Ch22
Warning in <TH1::Build>: Replacing existing histogram: Adc;Run0;Ch22 (Potential memory leak).
Prjocetion has been done!
Adc;Run0;Ch23
hAdc has been initialized!
Col == 2 && Row == 7

 *** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library "/lib/tls/libthread_db.so.1".
Attaching to program: /proc/8586/exe, process 8586
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
[New Thread -1208142144 (LWP 8586)]
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
0x008cc7a2 in _dl_sysinfo_int80 ()
   from /lib/ld-linux.so.2
#1  0x0100dd23 in __waitpid_nocancel () from /lib/tls/libc.so.6
#2  0x00fb77a9 in do_system () from /lib/tls/libc.so.6
#3  0x007a498d in system () from /lib/tls/libpthread.so.0
#4  0x00b2e7e7 in TUnixSystem::Exec ()
   from /misc/babar3/bomben/root/lib/libCore.so
#5  0x00b33f79 in TUnixSystem::StackTrace ()
   from /misc/babar3/bomben/root/lib/libCore.so
#6  0x00b30bd9 in TUnixSystem::DispatchSignals ()
   from /misc/babar3/bomben/root/lib/libCore.so
#7  0x00b30ce0 in SigHandler () from /misc/babar3/bomben/root/lib/libCore.so
#8  0x00b2feb9 in sighandler () from /misc/babar3/bomben/root/lib/libCore.so
#9  <signal handler called>
#10 0x08906490 in ?? ()
#11 0x00c13178 in G__G__Base2_9_0_26 ()
   from /misc/babar3/bomben/root/lib/libCore.so
#12 0x0014d4af in Cint::G__ExceptionWrapper ()
   from /misc/babar3/bomben/root/lib/libCint.so
#13 0x0016b255 in G__exec_asm () from /misc/babar3/bomben/root/lib/libCint.so
#14 0x00229ad9 in G__exec_loop () from /misc/babar3/bomben/root/lib/libCint.so
#15 0x00229d4c in G__exec_for () from /misc/babar3/bomben/root/lib/libCint.so
#16 0x0022766f in G__exec_statement ()
   from /misc/babar3/bomben/root/lib/libCint.so
#17 0x002295f0 in G__exec_loop () from /misc/babar3/bomben/root/lib/libCint.so
#18 0x00229e66 in G__exec_while () from /misc/babar3/bomben/root/lib/libCint.so
#19 0x00228077 in G__exec_statement ()
   from /misc/babar3/bomben/root/lib/libCint.so
#20 0x001ab7a8 in G__exec_tempfile_core ()
   from /misc/babar3/bomben/root/lib/libCint.so
#21 0x001aba18 in G__exec_tempfile ()
   from /misc/babar3/bomben/root/lib/libCint.so
#22 0x00234eb7 in G__process_cmd ()
   from /misc/babar3/bomben/root/lib/libCint.so
#23 0x00b03728 in TCint::ProcessLine ()
   from /misc/babar3/bomben/root/lib/libCore.so
#24 0x00b03803 in TCint::ProcessLineSynch ()
   from /misc/babar3/bomben/root/lib/libCore.so
#25 0x00a7e1bd in TApplication::ProcessFile ()
   from /misc/babar3/bomben/root/lib/libCore.so
#26 0x00a7c616 in TApplication::ProcessLine ()
   from /misc/babar3/bomben/root/lib/libCore.so
#27 0x00680d25 in TRint::Run () from /misc/babar3/bomben/root/lib/libRint.so
#28 0x08048d36 in main ()
Root >
root [1] .q

 *** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library "/lib/tls/libthread_db.so.1".
Attaching to program: /proc/8586/exe, process 8586
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
[New Thread -1208142144 (LWP 8586)]
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
0x008cc7a2 in _dl_sysinfo_int80 ()
   from /lib/ld-linux.so.2
#1  0x0100dd23 in __waitpid_nocancel () from /lib/tls/libc.so.6
#2  0x00fb77a9 in do_system () from /lib/tls/libc.so.6
#3  0x007a498d in system () from /lib/tls/libpthread.so.0
#4  0x00b2e7e7 in TUnixSystem::Exec ()
   from /misc/babar3/bomben/root/lib/libCore.so
#5  0x00b33f79 in TUnixSystem::StackTrace ()
   from /misc/babar3/bomben/root/lib/libCore.so
#6  0x00b30bd9 in TUnixSystem::DispatchSignals ()
   from /misc/babar3/bomben/root/lib/libCore.so
#7  0x00b30ce0 in SigHandler () from /misc/babar3/bomben/root/lib/libCore.so
#8  0x00b2feb9 in sighandler () from /misc/babar3/bomben/root/lib/libCore.so
#9  <signal handler called>
#10 0x088f73b0 in ?? ()
#11 0x00af4078 in TCollection::GarbageCollect ()
   from /misc/babar3/bomben/root/lib/libCore.so
#12 0x00af7db5 in TList::Delete () from /misc/babar3/bomben/root/lib/libCore.so
#13 0x00af5c14 in THashList::Delete ()
   from /misc/babar3/bomben/root/lib/libCore.so
#14 0x043cc79b in TDirectoryFile::Close ()
   from /misc/babar3/bomben/root/lib/libRIO.so
#15 0x043d9465 in TFile::Close () from /misc/babar3/bomben/root/lib/libRIO.so
#16 0x043d988c in TFile::~TFile$delete ()
   from /misc/babar3/bomben/root/lib/libRIO.so
#17 0x00af4078 in TCollection::GarbageCollect ()
   from /misc/babar3/bomben/root/lib/libCore.so
#18 0x00af7dc5 in TList::Delete () from /misc/babar3/bomben/root/lib/libCore.so
#19 0x00b2e890 in TUnixSystem::Exit ()
   from /misc/babar3/bomben/root/lib/libCore.so
#20 0x006821a9 in TRint::Terminate ()
   from /misc/babar3/bomben/root/lib/libRint.so
#21 0x00a7c1eb in TApplication::ProcessLine ()
   from /misc/babar3/bomben/root/lib/libCore.so
#22 0x00681f5d in TRint::HandleTermInput ()
   from /misc/babar3/bomben/root/lib/libRint.so
#23 0x006806e4 in TTermInputHandler::Notify ()
   from /misc/babar3/bomben/root/lib/libRint.so
#24 0x00682786 in TTermInputHandler::ReadNotify ()
   from /misc/babar3/bomben/root/lib/libRint.so
#25 0x00b2d172 in TUnixSystem::CheckDescriptors ()
   from /misc/babar3/bomben/root/lib/libCore.so
#26 0x00b31130 in TUnixSystem::DispatchOneEvent ()
   from /misc/babar3/bomben/root/lib/libCore.so
#27 0x00acd7a4 in TSystem::InnerLoop ()
   from /misc/babar3/bomben/root/lib/libCore.so
#28 0x00acd743 in TSystem::Run () from /misc/babar3/bomben/root/lib/libCore.so
#29 0x00a7c7d2 in TApplication::Run ()
   from /misc/babar3/bomben/root/lib/libCore.so
#30 0x00680e72 in TRint::Run () from /misc/babar3/bomben/root/lib/libRint.so
#31 0x08048d36 in main ()
Root >

I have no idea what is wrong… any idea is welcome!

Many thanks in advance!

Marco
ThresholdScan.C (2.31 KB)

I see at least one major problem in your code. You should replace

TH1F ***hAdc = new TH1F[21][128]; by

TH1F *hAdc[21][128];
If this does not solve your problem, we will need the shortest possible running script
and list of files reproducing the problem.

Rene

Hi,

please post the full output, if possible with the text and data files. Are you sure you’re not running out of memory? You seem to create a lot on the heap.

Cheers, Axel.

Dear Rene, Alex,
thank you very much for your suggestions.

I’ve changed the line:

TH1F ***hAdc = new TH1F[21][128];

to:

TH1F *hAdc[21][128];

and:

TString hName;
// ...
hName.Form("Adc;Run%d;Ch%d",nObjs,iCh);

to:

TString hName;
// ...
hName.Form("Adc-Run%d-Ch%d",nObjs,iCh);

The last one cured the warnings about the memory leakage.

Many thanks again!

Marco