Dear root users/devs,
I wrote some code (main file + class files) in order to perform interactive analysis, in interpreted mode (with cint, on ROOT 5.34.25), and cannot fix a bug.
Here is a simplification code that reflect my issue :
The main file main.cc
-> i’m running with $ root -l main.cc
#include "myclass.cc"
Int_t main(void)
{
myclass *a_myclass = new myclass();
a_myclass->createHisto();
a_myclass->fillHisto();
a_myclass->drawHisto();
return 0;
}
The myclass header file myclass.hh
class myclass
{
public:
myclass(void);
void createHisto(void);
void fillHisto(void);
void drawHisto(void);
private:
TCanvas *myCanvas;
TH1I *myHisto;
};
The myclass code file myclass.cc
#include "myclass.hh"
myclass::myclass(void)
{
cout << "-> myclass constructor is called" << endl;
myCanvas = NULL;
myHisto = NULL;
}
void myclass::createHisto(void)
{
if(!myCanvas) myCanvas = new TCanvas("myCanvas", "my canvas");
if(!myHisto) myHisto = new TH1I("myHisto", "my histo", 100, 0, 100);
}
void myclass::fillHisto(void)
{
myHisto->Fill(50);
}
void myclass::drawHisto(void)
{
if(myHisto) myHisto->Draw("");
else cout << "not ctreated !" << endl;
}
When running ($ root -l main.cc), the canvas+histo are displayed, but a crash occured :
$ rootl main.cc
root [0]
Processing main.cc...
-> myclass constructor is called
(Int_t)0
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00007fb1b97c914c in __libc_waitpid (pid=11430, stat_loc=stat_loc
entry=0x7fff1ce78ca0, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:31
#1 0x00007fb1b975318b in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2 0x00007fb1ba47fca4 in TUnixSystem::StackTrace() () from /opt/cern-root/git/lib/libCore.so
#3 0x00007fb1ba481dec in TUnixSystem::DispatchSignals(ESignals) () from /opt/cern-root/git/lib/libCore.so
#4 <signal handler called>
#5 0x00007fb1ba452131 in TDataMember::TDataMember(void*, TClass*) () from /opt/cern-root/git/lib/libCore.so
#6 0x00007fb1ba44c5d8 in TCint::CreateListOfDataMembers(TClass*) () from /opt/cern-root/git/lib/libCore.so
#7 0x00007fb1ba467f9f in TClass::GetListOfDataMembers() () from /opt/cern-root/git/lib/libCore.so
#8 0x00007fb1ba4680cb in TClass::GetDataMember(char const*) const () from /opt/cern-root/git/lib/libCore.so
#9 0x00007fb1ba460148 in ROOT::TSchemaRuleSet::AddRule(ROOT::TSchemaRule*, ROOT::TSchemaRuleSet::EConsistencyCheck, TString*) () from /opt/cern-root/git/lib/libCore.so
#10 0x00007fb1ba43dd64 in ROOT::TGenericClassInfo::CreateRuleSet(std::vector<ROOT::TSchemaHelper, std::allocator<ROOT::TSchemaHelper> >&, bool) () from /opt/cern-root/git/lib/libCore.so
#11 0x00007fb1ba43e265 in ROOT::TGenericClassInfo::GetClass() () from /opt/cern-root/git/lib/libCore.so
#12 0x00007fb1b6d8bf5c in TProfile::Class() () from /opt/cern-root/git/lib/libHist.so
#13 0x00007fb1b252d76b in THistPainter::PaintStat(int, TF1*) () from /opt/cern-root/git/lib/libHistPainter.so
#14 0x00007fb1b2512f8e in THistPainter::Paint(char const*) () from /opt/cern-root/git/lib/libHistPainter.so
#15 0x00007fb1b56d1049 in TPad::PaintModified() () from /opt/cern-root/git/lib/libGpad.so
#16 0x00007fb1b56eb3ac in TCanvas::Update() () from /opt/cern-root/git/lib/libGpad.so
#17 0x00007fb1ba445c51 in TCint::UpdateAllCanvases() () from /opt/cern-root/git/lib/libCore.so
#18 0x00007fb1ba445d80 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /opt/cern-root/git/lib/libCore.so
#19 0x00007fb1ba444b87 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /opt/cern-root/git/lib/libCore.so
#20 0x00007fb1b9ffd1e7 in TRint::Run(bool) () from /opt/cern-root/git/lib/libRint.so
#21 0x0000000000400fa0 in main ()
===========================================================
The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug 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 0x00007fb1ba452131 in TDataMember::TDataMember(void*, TClass*) () from /opt/cern-root/git/lib/libCore.so
#6 0x00007fb1ba44c5d8 in TCint::CreateListOfDataMembers(TClass*) () from /opt/cern-root/git/lib/libCore.so
#7 0x00007fb1ba467f9f in TClass::GetListOfDataMembers() () from /opt/cern-root/git/lib/libCore.so
#8 0x00007fb1ba4680cb in TClass::GetDataMember(char const*) const () from /opt/cern-root/git/lib/libCore.so
#9 0x00007fb1ba460148 in ROOT::TSchemaRuleSet::AddRule(ROOT::TSchemaRule*, ROOT::TSchemaRuleSet::EConsistencyCheck, TString*) () from /opt/cern-root/git/lib/libCore.so
#10 0x00007fb1ba43dd64 in ROOT::TGenericClassInfo::CreateRuleSet(std::vector<ROOT::TSchemaHelper, std::allocator<ROOT::TSchemaHelper> >&, bool) () from /opt/cern-root/git/lib/libCore.so
#11 0x00007fb1ba43e265 in ROOT::TGenericClassInfo::GetClass() () from /opt/cern-root/git/lib/libCore.so
#12 0x00007fb1b6d8bf5c in TProfile::Class() () from /opt/cern-root/git/lib/libHist.so
#13 0x00007fb1b252d76b in THistPainter::PaintStat(int, TF1*) () from /opt/cern-root/git/lib/libHistPainter.so
#14 0x00007fb1b2512f8e in THistPainter::Paint(char const*) () from /opt/cern-root/git/lib/libHistPainter.so
#15 0x00007fb1b56d1049 in TPad::PaintModified() () from /opt/cern-root/git/lib/libGpad.so
#16 0x00007fb1b56eb3ac in TCanvas::Update() () from /opt/cern-root/git/lib/libGpad.so
#17 0x00007fb1ba445c51 in TCint::UpdateAllCanvases() () from /opt/cern-root/git/lib/libCore.so
===========================================================
Does anybody have any idea/solution for this issue ?
Maybe I forgot something very evident … but I did’nt found out.
Thanks