Segmentation violation in creating tree file

Consider the attached files. When running EG_v2_tree.C and calling the function rootfuncgenerate, there is a segmentation violation. The aim is to produce a tree file phi_dist.root and be able to run tree->Draw() from the command line.

it seems that the upload/attachment of the file failed.

To debug things I recommend you follow the following step (to get a better of view of what might be wrong)
a) Compile the script with ACLiC: .L EG_v2_tree.C+
b) this might print several error (due to cling being more lenient syntax wise than the compiler.
c) Fix any of those errors.
d) compile again (and back to c) if needed)
e) run the script and see if it nows works.
f) if it fails, it should have given a stack trace that may make it clear what the problem is.
g) if the stack trace does not contain line number, recompile in debug mode: .L EG_v2_tree.C++g
h) run the script and see how it fails.
i) if the stack trace information is not good enough to understand the problem run with valgrind:
valgrind --suppressions=$ROOTSYS/etc/valgrind-root.supp root.exe -b -l -q .L EG_v2_tree.C+g
j) Check valgrind output, it should indicate the origin of many kind of memory.
k) if this is still unclear, provide a complete running (and failing :slight_smile: ) example as a reply to this post.

1 Like

Thanks for the reply. The problem has been solved - a minor error in the code.