How to debug macro using the stack trace

Hello,

Running root I get crashes sometimes and those return a stack trace, but I never knew how to use it to debug my macros. How can I use the stack trace to debug my code? Should I use gdb or gDebug? I know the line which produces the crash below but I do not know how to use the stack trace to get some solution for it. If I spend some time I’ll probably fix the error but it is probably faster if I know how to use the stack trace. Thanks!

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.
===========================================================
#6  0x00007fbe13cc2233 in draw() () from /home/macros/plots_cxx.so
#7  0x00007fbe24055066 in ?? ()
#8  0x000000010262cb28 in ?? ()
#9  0x000000000228fd90 in ?? ()
#10 0x00007fbe1e97a260 in ?? () from /opt/root_v6-14-06/build/lib/libCling.so
#11 0x00007ffcc8f844f0 in ?? ()
#12 0x00007ffcc8f840f0 in ?? ()
#13 0x00007fbe1e904c78 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) () from /opt/root_v6-14-06/build/lib/libCling.so
#14 0x00007fbe1e906245 in cling::Interpreter::EvaluateInternal(std::string const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /opt/root_v6-14-06/build/lib/libCling.so
#15 0x00007fbe1e90646a in cling::Interpreter::process(std::string const&, cling::Value*, cling::Transaction**, bool) () from /opt/root_v6-14-06/build/lib/libCling.so
#16 0x00007fbe1e9a0408 in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /opt/root_v6-14-06/build/lib/libCling.so
#17 0x00007fbe1e87217a in HandleInterpreterException (metaProcessor=0x262c770, input_line=0x7ffcc8f84439 "plots()", compRes=
0x7ffcc8f843dc: cling::Interpreter::kSuccess, result=0x7ffcc8f844f0) at /opt/root/core/metacling/src/TCling.cxx:2060
===========================================================

What is the line’s content.

How can I use the stack trace to debug my code?

To get a proper stack for a macro, you need to update it to make compileable (usually means making the code into a function and adding #include) and then to load the macro with ACLiC (i.e. add a trailing +).

Cheers,
Philippe.

Hello @pcanal, I found the source of the crash, I was using a pointer without initializing it (the crashes are often concerning pointers, I bit painful to find where). My main doubt is how to debug the code using the stack trace (if that is possible). I always compile the code with a trailing ++.

Cheers

Hi,

To get better stack trace in this case use:
++g

Cheers,
Philippe.

Hello @pcanal, using ++g I got the line where the crash happened. Although it does not say much about the error, it is a handful hint on the source of the crash. Thanks!

ps: the problem is solved, I just reproduced it again to check the trailing ++g.

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.
===========================================================
#6  0x00007f1c8c937ab2 in draw () at /home/macros/./Draw.C:312
#7  0x00007f1c8c9382a1 in plots () at /home/macros/./plots.cxx:11
#8  0x00007f1c9cce2066 in ?? ()
#9  0x00000001014fb208 in ?? ()
#10 0x0000000001459d90 in ?? ()
#11 0x00007f1c97607260 in ?? () from /opt/root_v6-14-06/build/lib/libCling.so
#12 0x00007ffe73a63af0 in ?? ()
#13 0x00007ffe73a636f0 in ?? ()
#14 0x00007f1c97591c78 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) () from /opt/root_v6-14-06/build/lib/libCling.so
#15 0x00007f1c97593245 in cling::Interpreter::EvaluateInternal(std::string const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /opt/root_v6-14-06/build/lib/libCling.so
#16 0x00007f1c9759346a in cling::Interpreter::process(std::string const&, cling::Value*, cling::Transaction**, bool) () from /opt/root_v6-14-06/build/lib/libCling.so
#17 0x00007f1c9762d408 in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /opt/root_v6-14-06/build/lib/libCling.so
#18 0x00007f1c974ff17a in HandleInterpreterException (metaProcessor=0x17b1220, input_line=0x7ffe73a63a39 "plots()", compRes=
0x7ffe73a639dc: cling::Interpreter::kSuccess, result=0x7ffe73a63af0) at /opt/root/core/metacling/src/TCling.cxx:2060
===========================================================