Crash in root 6.06/06 when using TMultiGraph

This two lines causes root to segfault

m = new TMultiGraph();
m->GetXaxis()->SetTimeDisplay(1);

*** Break *** segmentation violation

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

#0 0x00007fd2dda0065a in waitpid () from /lib64/libc.so.6
#1 0x00007fd2dd97b39b in do_system () from /lib64/libc.so.6
#2 0x00007fd2de5657f8 in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.6.06
#3 0x00007fd2de567acc in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib64/root/libCore.so.6.06
#4
#5 0x00007fd2decb3051 in ?? ()
#6 0x00007ffca7f13e40 in ?? ()
#7 0x00007ffca7f14120 in ?? ()
#8 0x00007fd2decb3000 in ?? ()
#9 0x00007fd2d9d2a974 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) () from /usr/lib64/root/libCling.so
#10 0x00007fd2d9d3099e in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**) () from /usr/lib64/root/libCling.so
#11 0x00007fd2d9d30af5 in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cling::Value*, cling::Transaction**) () from /usr/lib64/root/libCling.so
#12 0x00007fd2d9dcab0e in cling::MetaProcessor::process(char const*, cling::Interpreter::CompilationResult&, cling::Value*) () from /usr/lib64/root/libCling.so
#13 0x00007fd2d9cc23c6 in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /usr/lib64/root/libCling.so
#14 0x00007fd2de4576e9 in TApplication::ProcessLine(char const*, bool, int*) () from /usr/lib64/root/libCore.so.6.06
#15 0x00007fd2de881a7f in TRint::ProcessLineNr(char const*, char const*, int*) () from /usr/lib64/root/libRint.so.6.06
#16 0x00007fd2de881d56 in TRint::HandleTermInput() () from /usr/lib64/root/libRint.so.6.06
#17 0x00007fd2de566f6d in TUnixSystem::CheckDescriptors() () from /usr/lib64/root/libCore.so.6.06
#18 0x00007fd2de5683db in TUnixSystem::DispatchOneEvent(bool) () from /usr/lib64/root/libCore.so.6.06
#19 0x00007fd2de45bf84 in TSystem::InnerLoop() () from /usr/lib64/root/libCore.so.6.06
#20 0x00007fd2de45aadf in TSystem::Run() () from /usr/lib64/root/libCore.so.6.06
#21 0x00007fd2de454b6f in TApplication::Run(bool) () from /usr/lib64/root/libCore.so.6.06
#22 0x00007fd2de88319f in TRint::Run(bool) () from /usr/lib64/root/libRint.so.6.06
#23 0x0000560b5410f2cc in main ()

Hi,

the method TMultiGraph::GetXaxis() returns a valid axis only after being drawn as documented here:
root.cern.ch/doc/master/classTM … 5a65243cc8

Cheers,
D

1 Like

And if you are using this method inside a macro you need to issue a :

gPad->Update();

after:

m->Draw();

to make sure the axis are created.

I know that how to use it, but my point is that should it crash in this way?

OK, i got it, thanks a lot.

Hi,

you are using 6.06 and it’s great you solved the issue you were facing.
The forthcoming 6.08 version will include a null-pointer dereferencing detection mechanism which will be able, for interpreted macros and code typed at the prompt, an error message like the following one:

root [0] m = new TMultiGraph();
root [1] m->GetXaxis()->SetTimeDisplay(1);
Info in <Handle>: Trying to dereference null pointer or trying to call
routine taking non-null arguments.
Execution of your code was aborted.
ROOT_prompt_1:1:1: warning: null passed to a callee that requires a
non-null argument [-Wnonnull]
m->GetXaxis()->SetTimeDisplay(1);

Cheers,
D