Question of C++

___There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00000035148ac89e in waitpid () from /lib64/libc.so.6
#1  0x000000351483e4e9 in do_system () from /lib64/libc.so.6
#2  0x00007f3cb28b7737 in TUnixSystem::StackTrace() () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/core/unix/src/TUnixSystem.cxx:2119
#3  0x00007f3cb28b9d44 in TUnixSystem::DispatchSignals(ESignals) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/core/unix/src/TUnixSystem.cxx:3644
#4  <signal handler called>
#5  0x000000351487b93c in free () from /lib64/libc.so.6
#6  0x00000000004235d7 in MyBeamTestTrackAGET::AnalysisCluster(MyBeamTestData*) ()
#7  0x0000000000426b8a in MyBeamTestTrackAGET::ReadRaw2DstRoot(TString, TString, TString, std::vector<MyBeamTestTrackAGET*, std::allocator<MyBeamTestTrackAGET*> >, bool) ()
#8  0x000000000042dcaf in MyGuiBeamTest::ConvtRawToDstRoot() ()
#9  0x00000000004305fd in MyGuiMainAction::DoGenDSTRoot(TString) ()
#10 0x00000000004359f9 in MyGuiMainAction::ExecButtonClick(long, char const*) ()
#11 0x0000000000436622 in MyGuiMainFrame::ProcessMessage(long, long, long) ()
#12 0x00007f3caedf2189 in TGFrame::HandleClientMessage(Event_t*) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGFrame.cxx:657
#13 0x00007f3caedf3fdc in TGMainFrame::HandleClientMessage(Event_t*) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGFrame.cxx:1687
#14 0x00007f3caee019ef in TGFrame::HandleEvent(Event_t*) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGFrame.cxx:533
#15 0x00007f3caedb14b8 in TGClient::HandleEvent(Event_t*) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGClient.cxx:841
#16 0x00007f3caedb1b55 in TGClient::ProcessOneEvent() () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGClient.cxx:651
#17 0x00007f3caedb1bad in TGClient::HandleInput() () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGClient.cxx:698
#18 0x00007f3cb28ba578 in TUnixSystem::DispatchOneEvent(bool) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/core/unix/src/TUnixSystem.cxx:1067
#19 0x00007f3cb27d9389 in TSystem::Run() () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/core/base/src/TSystem.cxx:411
#20 0x00007f3cb276b24f in TApplication::Run(bool) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/core/base/src/TApplication.cxx:1173
#21 0x0000000000415f8f in main ()
===========================================================


The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x000000351487b93c in free () from /lib64/libc.so.6
#6  0x00000000004235d7 in MyBeamTestTrackAGET::AnalysisCluster(MyBeamTestData*) ()
#7  0x0000000000426b8a in MyBeamTestTrackAGET::ReadRaw2DstRoot(TString, TString, TString, std::vector<MyBeamTestTrackAGET*, std::allocator<MyBeamTestTrackAGET*> >, bool) ()
#8  0x000000000042dcaf in MyGuiBeamTest::ConvtRawToDstRoot() ()
#9  0x00000000004305fd in MyGuiMainAction::DoGenDSTRoot(TString) ()
#10 0x00000000004359f9 in MyGuiMainAction::ExecButtonClick(long, char const*) ()
#11 0x0000000000436622 in MyGuiMainFrame::ProcessMessage(long, long, long) ()
#12 0x00007f3caedf2189 in TGFrame::HandleClientMessage(Event_t*) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGFrame.cxx:657
#13 0x00007f3caedf3fdc in TGMainFrame::HandleClientMessage(Event_t*) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGFrame.cxx:1687
#14 0x00007f3caee019ef in TGFrame::HandleEvent(Event_t*) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGFrame.cxx:533
#15 0x00007f3caedb14b8 in TGClient::HandleEvent(Event_t*) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGClient.cxx:841
#16 0x00007f3caedb1b55 in TGClient::ProcessOneEvent() () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGClient.cxx:651
#17 0x00007f3caedb1bad in TGClient::HandleInput() () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/gui/gui/src/TGClient.cxx:698
#18 0x00007f3cb28ba578 in TUnixSystem::DispatchOneEvent(bool) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/core/unix/src/TUnixSystem.cxx:1067
#19 0x00007f3cb27d9389 in TSystem::Run() () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/core/base/src/TSystem.cxx:411
#20 0x00007f3cb276b24f in TApplication::Run(bool) () at /software/STCF/Oscar_pre2.0/ExternalLibs/Build/root-6.13.06/root-6.13.06/core/base/src/TApplication.cxx:1173
#21 0x0000000000415f8f in main ()

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hello,

Please provide some context of this crash. It looks like coming from an application built on top of ROOT. It would be also helpful to know the ROOT version, the operating system, and if possible a minimal reproducer.

Cheers,
Jakob

Hello,
After I add the code to the program,the problem arise.These sentences are as follows:

if(fEvent->XYbranch[0][j][x[0]].q<fEvent->XYbranch[0][j][x[slen-1]].q)
                {
                 for(int jj=0;jj<slen-3;jj++){
                 auto iter=fEvent->XYbranch[0][j].begin()+x[jj];
                   fEvent->XYbranch[0][j].erase(iter);
                       }
                }
                
                else
                {   
                    for(int jj=3;jj<slen;jj++){
                       auto iter=fEvent->XYbranch[0][j].begin()+x[jj];
                       fEvent->XYbranch[0][j].erase(iter);}
                }

the function of erase() is newly initiated.
ROOT version is root-6.13.06.
Thanks,
jblomer

I’m afraid without more context this is hard to debug. Please try to attach a minimal but complete macro that reproduces the problem.

MyBeamTestTrackAGET.cpp (40.1 KB)
the part of erase.() is newly initiated.Befor this,there’s no problem.

I think the problem is that your loop still runs until nbranch. Meanwhile, however, you are erasing elements so towards the end of the loop fEvent->XYbranch[0][j] will try to access non-existing elements.

Thank you,jblomer