# Segmentation violation in creating tree file

**URL:** <https://root-forum.cern.ch/t/segmentation-violation-in-creating-tree-file/36717>\
**Category:** Newbie\
**Created:** [November 6, 2019, 4:52pm UTC](https://root-forum.cern.ch/t/segmentation-violation-in-creating-tree-file/36717 "2019-11-06T16:52:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![schniefen](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@schniefen](https://root-forum.cern.ch/u/schniefen)\
**Post date:** [November 6, 2019, 4:52pm UTC](https://root-forum.cern.ch/t/segmentation-violation-in-creating-tree-file/36717/1 "2019-11-06T16:52:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [November 12, 2019, 9:35pm UTC](https://root-forum.cern.ch/t/segmentation-violation-in-creating-tree-file/36717/2 "2019-11-12T21:35:55Z")

</div>

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 🙂 ) example as a reply to this post.

---

<div class="post-metadata">

**Author:** ![schniefen](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@schniefen](https://root-forum.cern.ch/u/schniefen)\
**Post date:** [November 12, 2019, 9:50pm UTC](https://root-forum.cern.ch/t/segmentation-violation-in-creating-tree-file/36717/3 "2019-11-12T21:50:10Z")

</div>

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