Crash problem

I am trying to read two histogram from .root file and plot it after rescaling but i am getting the following error
Root > .L plotHistograms.C
root [4] plotHistograms()
Warning in TCanvas::Constructor: Deleting canvas with same name: canvas
Info in TCanvas::Print: file histograms.png has been created

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

#0 0x00007fe50888e60c in waitpid () from /lib64/libc.so.6
#1 0x00007fe50880bf62 in do_system () from /lib64/libc.so.6
#2 0x00007fe5095b9a5c in TUnixSystem::StackTrace() () from /cvmfs/sft.cern.ch/lcg/releases/ROOT/6.26.04-edd28/x86_64-centos7-gcc11-opt/bin/…/lib/libCore.so
#3 0x00007fe5095b7155 in TUnixSystem::DispatchSignals(ESignals) () from /cvmfs/sft.cern.ch/lcg/releases/ROOT/6.26.04-edd28/x86_64-centos7-gcc11-opt/bin/…/lib/libCore.so
#4
#5 0x000000000432ff30 in ?? ()
#6 0x00007fe50985746d in ?? ()
#7 0x00007fe503a81cb0 in ?? () from /cvmfs/sft.cern.ch/lcg/views/LCG_102/x86_64-centos7-gcc11-opt/lib/libCling.so
#8 0x00000000015bd960 in ?? ()
#9 0x0000000003ec02e0 in ?? ()
#10 0x0000000003545d50 in ?? ()
#11 0x00007fe50985607a in ?? ()
#12 0x0000000004294250 in ?? ()
#13 0x00000000042c4790 in ?? ()
#14 0x0000000103aa239c in ?? ()
#15 0x3c23d70a00000002 in ?? ()
#16 0x403e000000000000 in ?? ()
#17 0x0000000004294250 in ?? ()
#18 0x00000000042c4790 in ?? ()
#19 0x0000000000000000 in ?? ()

The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum ROOT Forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at Sign in to GitHub · GitHub Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.

#5 0x000000000432ff30 in ?? ()
#6 0x00007fe50985746d in ?? ()
#7 0x00007fe503a81cb0 in ?? () from /cvmfs/sft.cern.ch/lcg/views/LCG_102/x86_64-centos7-gcc11-opt/lib/libCling.so
#8 0x00000000015bd960 in ?? ()
#9 0x0000000003ec02e0 in ?? ()
#10 0x0000000003545d50 in ?? ()
#11 0x00007fe50985607a in ?? ()
#12 0x0000000004294250 in ?? ()
#13 0x00000000042c4790 in ?? ()
#14 0x0000000103aa239c in ?? ()
#15 0x3c23d70a00000002 in ?? ()
#16 0x403e000000000000 in ?? ()
#17 0x0000000004294250 in ?? ()
#18 0x00000000042c4790 in ?? ()
#19 0x0000000000000000 in ?? ()

.root file and cpp script are attached,
-200V_pulsgraph.root (447.0 KB)
plotHistograms.C (1.5 KB)
i will be thankful for your tips
Faiz

Dear Faiz,

Thanks for the post and the nicely written macro.
The problem is that you are deleting the pointers to the two histograms, that you do not own, since they are owned by the file, that you correctly close.
Just remove line 49 and 50 and everything will work properly:

    delete hist1;
    delete hist2;

I hope it helps!

Cheers,
Danilo

Thank you very much Danilo, that worked.

1 Like