Annoying seg flt :evil:

Dear reader,

I have a script that opens a file and makes a few plots, also TStacks. No problems so far, but when I want to quit root `.q’, I get the next seg flt… not really understand it:

*** Break *** segmentation violation
Generating stack trace…
0x40154848 in TList::Delete(char const*) + 0xf4 from /usr/local/root/lib/libCore.so
0x407bcf06 in THStack::~THStack in-charge deleting + 0x3e from /usr/local/root/lib/libHist.so
0x408857e2 in from /usr/local/root/lib/libHist.so
0x405aa5da in G__call_cppfunc + 0x263 from /usr/local/root/lib/libCint.so
0x4059a39c in G__interpret_func + 0x6e1 from /usr/local/root/lib/libCint.so
0x405829a3 in G__getfunction + 0x1295 from /usr/local/root/lib/libCint.so
0x405dea89 in G__destroy_upto + 0x367 from /usr/local/root/lib/libCint.so
0x405de772 in G__destroy_upto + 0x50 from /usr/local/root/lib/libCint.so
0x405de772 in G__destroy_upto + 0x50 from /usr/local/root/lib/libCint.so
0x405de772 in G__destroy_upto + 0x50 from /usr/local/root/lib/libCint.so
0x405de772 in G__destroy_upto + 0x50 from /usr/local/root/lib/libCint.so
0x405de772 in G__destroy_upto + 0x50 from /usr/local/root/lib/libCint.so
0x405de772 in G__destroy_upto + 0x50 from /usr/local/root/lib/libCint.so
0x405de772 in G__destroy_upto + 0x50 from /usr/local/root/lib/libCint.so
0x405de716 in G__scratch_globals_upto + 0x27 from /usr/local/root/lib/libCint.so
0x4015d931 in TCint::ResetGlobals() + 0x21 from /usr/local/root/lib/libCore.so
0x400e36cc in TApplication::ProcessLine(char const*, bool, int*) + 0x7a from /usr/local/root/lib/libCore.so
0x40d3fea6 in TRint::HandleTermInput() + 0x1b2 from /usr/local/root/lib/libRint.so
0x40d3edd8 in TTermInputHandler::Notify() + 0x24 from /usr/local/root/lib/libRint.so
0x40d406ec in TTermInputHandler::ReadNotify() + 0x12 from /usr/local/root/lib/libRint.so
0x401bd53f in TUnixSystem::CheckDescriptors() + 0xed from /usr/local/root/lib/libCore.so
0x401bcd14 in TUnixSystem::DispatchOneEvent(bool) + 0x10a from /usr/local/root/lib/libCore.so
0x40130551 in TSystem::InnerLoop() + 0x1b from /usr/local/root/lib/libCore.so
0x401304ea in TSystem::Run() + 0x78 from /usr/local/root/lib/libCore.so
0x400e4617 in TApplication::Run(bool) + 0x2d from /usr/local/root/lib/libCore.so
0x40d3f9d2 in TRint::Run(bool) + 0x2e4 from /usr/local/root/lib/libRint.so
0x08048861 in main + 0x71 from /usr/local/root/bin/root.exe
0x42015574 in __libc_start_main + 0xe4 from /lib/tls/libc.so.6
0x08048761 in _Unwind_Resume + 0x31 from /usr/local/root/bin/root.exe
Root >

In my script I have statements like:

{

gROOT->Reset();

TFile file(“28AllInfo.root”);

TCanvas C_Topos(“C_Topos”,“Topologies”,15,15, 900,900);
C_Topos.Divide(2,2);
C_Topos.cd(1);

THStack S_M_lepnu(“S_lepnu”,“Stacked M_{lep#nu}'s”);
S_M_lepnu.Add(H_Melnu_noscat);
S_M_lepnu.Add(H_Melnu_scat);
S_M_lepnu.Add(H_Mmunu_noscat);
S_M_lepnu.Add(H_Mmunu_scat);
S_M_lepnu.Draw();

TLegend L_lepnu(.12,.77,.5,.88);
L_lepnu.AddEntry( &H_Melnu_noscat,“el#nu NOSCAT”,“F”);
L_lepnu.AddEntry( &H_Melnu_scat, “el#nu SCAT”,“F”);
L_lepnu.AddEntry( &H_Mmunu_noscat,"#mu#nu NOSCAT",“F”);
L_lepnu.AddEntry( &H_Mmunu_scat, “#mu#nu SCAT”,“F”);
L_lepnu.Draw();

C_Topos.cd(2);

etc…

}

If you have any idea, very many thanks in advance, this is a bit annoying 'cause I can’t run the script in the same root session (on top of that I can’t shut down root fast).

Cheers,

Ytsen. :imp:

This problem happens with Root versions older than 4.01/02 when deleting the histograms referenced by THStack before deleting the THStack itself.

Rene

But aren’t the TStacks deleted the moment I close the TCanvases? Then, when I declare the TFile as `new’, the histos in the file would live longer than the TStacks. At least, I thought so. But that does not work neither. Is there another trick I could try?

THStacks are not deleted when you clear or close the canvas.

Rene