I’m stuck with this annoying segmentation fault when checking if a pointer is 0. This is the problematic code:
bool egammaMVACalib::checkTree()
{
// Not a TChain
cout << "a" << endl;
assert(m_tree); // crash on line 751 (this one)
cout << "B" << endl;
m_tree is a data member of egammaMVACalib of type TTree* so I really don’t understand why an assert(m_tree) can raise a segmentation violation. This is the output with the stack trace
a
19:07:25 30574 Wrk-0.9 | *** Break ***: segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x000000361869a4d5 in waitpid () from /lib64/libc.so.6
#1 0x000000361863c481 in do_system () from /lib64/libc.so.6
#2 0x00002ac5099cb322 in TUnixSystem::StackTrace() ()
from /usr/local/proof/root/lib/libCore.so
#3 0x00002ac5099c7fea in TUnixSystem::DispatchSignals(ESignals) ()
from /usr/local/proof/root/lib/libCore.so
#4 <signal handler called>
#5 egammaMVACalib::checkTree (this=0x0) at ../Root/egammaMVACalib.cxx:751
#6 0x00002ac5117e5563 in egammaMVACalib::LoadVariables (this=0x1, index=0)
at ../Root/egammaMVACalib.cxx:492
If you look at frame #5 your
thispointer is null. Which means the problem started there. Seg fault at the assertion is merely the repurcusion of that !