Segmentation Fault

I have some code which goes through a list of root data files, allows me to select a particular area of a 2D histogram (using TCut) and then plot the gamma ray energies associated with a detector (say Branch “NAI_19_E”) in a 1D Histo only when those gamma rays are coincident with that TCut set on the 2D Histo.

Apart from some random segmentation faults, the code does what I require it to do.I shall copy the error and code below. Any help is appreciated.

============THE CODE=======================


ifstream infile;"/home/nppatt/bin/files.dat");
if (!infile) {
cout << “Can’t load files” << endl;
Int_t i;
char filename[100];
char name[100];
UShort_t channel19;

TCanvas c1(“CHIO:TTRI_PL”);
TCanvas c2(“NAI19”);

TH1F *na19 = new TH1F(“na19”,“Na19”,16000,0,16000);

while (!infile.eof()) {
if (filename[0] == '’) {
cout <>hsqrt(1000,6000,7200,1000,1500,6000)","",“colz”);
tt->Draw(">> list",name);
list = (TEventList*) gDirectory->Get(“list”);
Int_t nentry = list->GetN();
cout << nentry << endl;

for (Int_t j=0;jGetEntry(list->GetEntry(j));



*** Break *** segmentation violation
Generating stack trace…
0xb4bd75e3 in TH1Editor::SetModel(TVirtualPad*, TObject*, int) + 0x1fbd from /home/nppatt/root/lib/
0xb4bc4f62 in TGedEditor::SetModel(TVirtualPad*, TObject*, int) + 0x1c4 from /home/nppatt/root/lib/
0xb4c4befa in from /home/nppatt/root/lib/
0xb749cd1f in G__CallFunc::Execute(void*) + 0xc3 from /home/nppatt/root/lib/
0xb78c1cf5 in TQConnection::ExecuteMethod(long*, int) + 0xdd from /home/nppatt/root/lib/
0xb78c5a1e in TQObject::Emit(char const*, long*) + 0x234 from /home/nppatt/root/lib/
0xb6db6f5d in TCanvas::Selected(TVirtualPad*, TObject*, int) + 0x43 from /home/nppatt/root/lib/
0xb6db6eb3 in TCanvas::Pick(int, int, TObject*) + 0x12d from /home/nppatt/root/lib/
0xb6dbb86f in TCanvas::HandleInput(EEventType, int, int) at TCanvas.cxx:0 from /home/nppatt/root/lib/
0xb61d66d0 in TRootCanvas::HandleContainerButton(Event_t*) + 0x86 from /home/nppatt/root/lib/
0xb61d7399 in TRootContainer::HandleButton(Event_t*) + 0xdb from /home/nppatt/root/lib/
0xb614107d in TGFrame::HandleEvent(Event_t*) at TGFrame.cxx:0 from /home/nppatt/root/lib/
0xb611806d in TGClient::HandleEvent(Event_t*) + 0xef from /home/nppatt/root/lib/
0xb61180e9 in TGClient::ProcessOneEvent() + 0x67 from /home/nppatt/root/lib/
0xb611818e in TGClient::HandleInput() + 0x24 from /home/nppatt/root/lib/
0xb61181c6 in TGInputHandler::Notify() + 0x20 from /home/nppatt/root/lib/
0xb79c9c82 in TUnixSystem::DispatchOneEvent(bool) + 0x50 from /home/nppatt/root/lib/
0xb78e3df2 in TSystem::ProcessEvents() + 0x42 from /home/nppatt/root/lib/
0xb6dd87fa in TPad::WaitPrimitive(char const*, char const*) + 0x140 from /home/nppatt/root/lib/
0xb6dfb648 in from /home/nppatt/root/lib/
0xb745e99d in G__ExceptionWrapper + 0x57 from /home/nppatt/root/lib/
0xb7482897 in G__exec_asm at bc_exec.cxx:0 from /home/nppatt/root/lib/
0xb7535ede in G__exec_loop + 0x624 from /home/nppatt/root/lib/
0xb753636e in G__exec_while + 0x92 from /home/nppatt/root/lib/
0xb75345ce in G__exec_statement at v6_parse.cxx:0 from /home/nppatt/root/lib/
0xb74bd3aa in G__exec_tempfile_core + 0x35c from /home/nppatt/root/lib/
0xb74bd5e0 in G__exec_tempfile + 0x2e from /home/nppatt/root/lib/
0xb75404b6 in G__process_cmd + 0x4ff8 from /home/nppatt/root/lib/
0xb7933083 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) + 0x129 from /home/nppatt/root/lib/
0xb7930500 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) + 0x4a from /home/nppatt/root/lib/
0xb78679d7 in TApplication::ProcessFile(char const*, int*) + 0x62b from /home/nppatt/root/lib/
0xb78648e0 in TApplication::ProcessLine(char const*, bool, int*) + 0x63e from /home/nppatt/root/lib/
0xb697572c in TRint::Run(bool) + 0x234 from /home/nppatt/root/lib/
0x08048d17 in main + 0x87 from /home/nppatt/root/bin/root.exe
0xb6727ea2 in __libc_start_main + 0xd2 from /lib/tls/i686/cmov/
0x08048c11 in TApplicationImp::ShowMembers(TMemberInspector&, char*) + 0x31 from /home/nppatt/root/bin/root.exe
CHIO_TTRI_PL.cpp (1.2 KB)


Can you, please, attach your script or use “code” tags and disable HTML in your post?


In addition, please provide information about your environment - ROOT version in use, operating system, etc.

Thank you, Ilka

I am using Root 5.11/02 installed on Ubuntu Linux 6.02

I should also note, that this segmentation fault occurs when I click on the 1D histogram to Rebin. However it does not occur everytime.


The file /home/nppatt/bin/files.dat is missing. Can you put it in some public place and provide the link.

Thanks, Ilka

Here is the list of files attached, but the .root files are very large and I cannot attach an example root file for you to run the code with.
files.tar.gz (198 Bytes)

Could you post somewhere in a public area (AFS, http) your root files that may help to reproduce the problem? If possible to reproduce it by using one root file, please change your .dat file and put it at the same location.

Cheers, Ilka

I have placed one root file at the following address.

If you use the “files.dat” file to open and draw a cut on the same file a number of times (rather than opening and drawing a TCut on different files) it should have the same effect.


You have to give access permission to .root file. Currently I am getting the message: “Forbidden: You don’t have permission to access /~php2np/Run646.root on this server.”

Cheers, Ilka

I have changed the permission and you should have access to download the file.

Many thanks, Nick

Hi Nick,

Thank you for provided access - I was able to copy your file. I have reduced the number of files in files.dat to three. Running ‘carefully’ your macro, I see no problem. The output is:root [0] .x CHIO_TTRI_PL.cpp Run646.root Mg1 572 Run646.root Mg2 100 Run646.root Mg3 194894 Break I used ‘carefully’ because a fast double-click in the beginning of defining TCutG provokes SegV.

Cheers, Ilka

Hi Nick,

A protection was added in cvs head to avoid the Segmentation fault when a graphical cut starts with double mouse clicks. Let me know if you want to fix your ROOT version (in case it was installed from source).

Cheers, Ilka

Thanks Ilka, I would like to fix this problem. Also, do you get a segmentation fault when you try and click on the 1D histogram and rebin? This is the most troublesome error.

Hi Nick,

No, I did not get that SegV. The only one I saw was fixed. If you could, please move to the recent version of ROOT v5.14. There were several improvements of TH1/TH2Editors. If you cannot, please describe the steps to follow for reproducing the problem.

Cheers, Ilka


I have actually upgraded to 5.14 already so this problem occurs using the latest source from thr root website.

Essentially, if you click on the 1D histogram in order to rebin a segmentation fault occurs. It doesn’t always happen first time, but if you keep drawing cuts to update and append counts to the 1D histo you reach a point where a segmentation fault occurs and you are left in a state where you can no longer rebin.

In the example below, I draw cuts for 12 files, then on the last file the macro breaks having filled the histogram. When you click on the 1D histo using the cursor, immediately you get a SegV.

root [1]
*** Break *** segmentation violation
Generating stack trace…
0xb5b1655f in TH1Editor::SetModel(TVirtualPad*, TObject*, int) + 0x1f39 from /home/nppatt/root/lib/
0xb5b03f62 in TGedEditor::SetModel(TVirtualPad*, TObject*, int) + 0x1c4 from /home/nppatt/root/lib/
0xb5b8aefa in from /home/nppatt/root/lib/
0xb7497d1f in G__CallFunc::Execute(void*) + 0xc3 from /home/nppatt/root/lib/
0xb78bccf5 in TQConnection::ExecuteMethod(long*, int) + 0xdd from /home/nppatt/root/lib/
0xb78c0a1e in TQObject::Emit(char const*, long*) + 0x234 from /home/nppatt/root/lib/
0xb6db1f5d in TCanvas::Selected(TVirtualPad*, TObject*, int) + 0x43 from /home/nppatt/root/lib/
0xb6db1eb3 in TCanvas::Pick(int, int, TObject*) + 0x12d from /home/nppatt/root/lib/
0xb6db686f in TCanvas::HandleInput(EEventType, int, int) at TCanvas.cxx:0 from /home/nppatt/root/lib/
0xb61d16d0 in TRootCanvas::HandleContainerButton(Event_t*) + 0x86 from /home/nppatt/root/lib/
0xb61d2399 in TRootContainer::HandleButton(Event_t*) + 0xdb from /home/nppatt/root/lib/
0xb613c07d in TGFrame::HandleEvent(Event_t*) at TGFrame.cxx:0 from /home/nppatt/root/lib/
0xb611306d in TGClient::HandleEvent(Event_t*) + 0xef from /home/nppatt/root/lib/
0xb61130e9 in TGClient::ProcessOneEvent() + 0x67 from /home/nppatt/root/lib/
0xb611318e in TGClient::HandleInput() + 0x24 from /home/nppatt/root/lib/
0xb61131c6 in TGInputHandler::Notify() + 0x20 from /home/nppatt/root/lib/
0xb79c4c82 in TUnixSystem::DispatchOneEvent(bool) + 0x50 from /home/nppatt/root/lib/
0xb78deda5 in TSystem::InnerLoop() + 0x21 from /home/nppatt/root/lib/ 0xb78ded43 in TSystem::Run() + 0x71 from /home/nppatt/root/lib/
0xb785ec30 in TApplication::Run(bool) + 0x34 from /home/nppatt/root/lib/
0xb69708a0 in TRint::Run(bool) + 0x3a8 from /home/nppatt/root/lib/
0x08048d17 in main + 0x87 from /home/nppatt/root/bin/root.exe
0xb6722ea2 in __libc_start_main + 0xd2 from /lib/tls/i686/cmov/
0x08048c11 in TApplicationImp::ShowMembers(TMemberInspector&, char*) + 0x31 from /home/nppatt/root/bin/root.exe
Root >
root [1]

Hi Nick,

The signature of TH1Editor::SetModel method was changed in September 2006 and currently isvoid TH1Editor::SetModel(TObject* obj)One I see in your last post isTH1Editor::SetModel(TVirtualPad*, TObject*, int) That is confusing. Have you run “make distclean” before compiling the sources of v5.14?

Cheers, Ilka

Thanks Ilka.
I reinstalled the 5.14 source , doing a make distclean before hand. It would appear for now that my Segmentation Fault has dissapeared and the macro seems to running ok.

Thanks for you help.

OH no. Spoke too soon. Now I have this.

*** Break *** segmentation violation
Using host libthread_db library “/lib/tls/i686/cmov/”.
Attaching to program: /proc/28593/exe, process 28593
[Thread debugging using libthread_db enabled]
[New Thread -1234889024 (LWP 28593)]
0xffffe410 in __kernel_vsyscall ()
#1 0xb670b933 in waitpid () from /lib/tls/i686/cmov/
#2 0xb66b53c9 in strtold_l () from /lib/tls/i686/cmov/
#3 0xb67ba7dd in system () from /lib/tls/i686/cmov/
#4 0xb79d936d in TUnixSystem::Exec () from /home/nppatt/root/lib/
#5 0xb79e179e in TUnixSystem::StackTrace ()
from /home/nppatt/root/lib/
#6 0xb79e0a5f in TUnixSystem::DispatchSignals ()
from /home/nppatt/root/lib/
#7 0xb79e0bf9 in SigHandler () from /home/nppatt/root/lib/
#8 0xb79da394 in sighandler () from /home/nppatt/root/lib/
#10 0xb37902dc in TH1Editor::SetModel () from /home/nppatt/root/lib/
#11 0xb377e0bc in TGedEditor::ConfigureGedFrames ()
from /home/nppatt/root/lib/
#12 0xb377e46f in TGedEditor::SetModel () from /home/nppatt/root/lib/
#13 0xb37f6213 in G__G__Ged_257_0_28 () from /home/nppatt/root/lib/
#14 0xb74181dd in Cint::G__CallFunc::Execute ()
from /home/nppatt/root/lib/
#15 0xb78d3952 in TQConnection::ExecuteMethod ()
from /home/nppatt/root/lib/
#16 0xb78d75ee in TQObject::Emit () from /home/nppatt/root/lib/
#17 0xb6d09e23 in TCanvas::Selected () from /home/nppatt/root/lib/
#18 0xb6d09d79 in TCanvas::Pick () from /home/nppatt/root/lib/
#19 0xb6d0e869 in TCanvas::HandleInput () from /home/nppatt/root/lib/
#20 0xb6122dd8 in TRootCanvas::HandleContainerButton ()
from /home/nppatt/root/lib/
#21 0xb6123b75 in TRootContainer::HandleButton ()
from /home/nppatt/root/lib/
#22 0xb60796e1 in TGFrame::HandleEvent () from /home/nppatt/root/lib/
#23 0xb604bcdd in TGClient::HandleEvent () from /home/nppatt/root/lib/
#24 0xb604bd59 in TGClient::ProcessOneEvent ()
from /home/nppatt/root/lib/
#25 0xb604bdfe in TGClient::HandleInput () from /home/nppatt/root/lib/
#26 0xb604be36 in TGInputHandler::Notify ()
from /home/nppatt/root/lib/
#27 0xb79e0ee6 in TUnixSystem::DispatchOneEvent ()
from /home/nppatt/root/lib/
#28 0xb78f74f8 in TSystem::ProcessEvents ()
from /home/nppatt/root/lib/
#29 0xb6d2b46c in TPad::WaitPrimitive () from /home/nppatt/root/lib/
#30 0xb6d4e439 in G__G__GPad_207_0_199 () from /home/nppatt/root/lib/
#31 0xb73d9afd in Cint::G__ExceptionWrapper ()
from /home/nppatt/root/lib/
#32 0xb73fe4b1 in G__exec_asm () from /home/nppatt/root/lib/
#33 0xb74b1019 in G__exec_loop () from /home/nppatt/root/lib/
#34 0xb74b14ae in G__exec_while () from /home/nppatt/root/lib/
#35 0xb74af6ee in G__exec_statement () from /home/nppatt/root/lib/
#36 0xb7438604 in G__exec_tempfile_core ()
from /home/nppatt/root/lib/
#37 0xb743883a in G__exec_tempfile () from /home/nppatt/root/lib/
#38 0xb74bb666 in G__process_cmd () from /home/nppatt/root/lib/
#39 0xb7944074 in TCint::ProcessLine () from /home/nppatt/root/lib/
#40 0xb794121c in TCint::ProcessLineSynch ()
from /home/nppatt/root/lib/
#41 0xb7875e37 in TApplication::ProcessFile ()
from /home/nppatt/root/lib/
#42 0xb7872d40 in TApplication::ProcessLine ()
from /home/nppatt/root/lib/
#43 0xb68e23ea in TRint::Run () from /home/nppatt/root/lib/
#44 0x08048d17 in main ()

Hi Nick,

Well, to avoid the previous bug, please change the line 409 in gpad/src/TCreatePrimitives.cxx from:if (mode == kCutG) {to:if (mode == kCutG && gr) { and let me know do you still get this crash.

Thank you, Ilka