# TTree as member variable

**URL:** <https://root-forum.cern.ch/t/ttree-as-member-variable/18147>\
**Category:** ROOT\
**Created:** [September 3, 2014, 3:59pm UTC](https://root-forum.cern.ch/t/ttree-as-member-variable/18147 "2014-09-03T15:59:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![explorer\_dude](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e5b9ba/32.png) [@explorer\_dude](https://root-forum.cern.ch/u/explorer_dude)\
**Post date:** [September 3, 2014, 3:59pm UTC](https://root-forum.cern.ch/t/ttree-as-member-variable/18147/1 "2014-09-03T15:59:15Z")

</div>

Dear Rootonians,

we are having a little trouble with some custom object we would like to store to root files. While trying to create a minimum breaking example, we hit the breaking point a little sooner than expected. In short, we want to save the following object to file:

```auto
class storage : public TObject
{

  public:

	TTree* tree;

	ClassDef(storage, 1);

};
```

This seems to work at the beginning. However, when trying to read the object from file, we get a segmentation violation in the streamer:

> [@](#):
>
> # =========================================================== #10 0x00007fb2eda609d9 in ROOT::delete\_TTree(void\*) () from /opt/root/from-git/lib/libTree.so #11 0x00007fb2f2622a7a in TClass::Destructor (this=0x27b4120, obj=0x9999999999999999, dtorOnly=false) at /opt/root/from-git/core/meta/src/TClass.cxx:4373 #12 0x00007fb2ee882755 in TBufferFile::ReadFastArray (this=0x2897710, start=0x2a2d550, cl=0x27b4120, n=1, isPreAlloc=false, streamer=0x0, onFileClass=0x0) at /opt/root/from-git/io/io/src/TBufferFile.cxx:1639 #13 0x00007fb2eea8993b in TStreamerInfo::ReadBuffer\<char\*\*\> (this=0x2888ef0, b=…, arr= 0x7fffa15ead90: 0x7fffa15ead88, compinfo=0x2890438, first=0, last=1, narr=1, eoffset=0, arrayMode=0) at /opt/root/from-git/io/io/src/TStreamerInfoReadBuffer.cxx:1087 #14 0x00007fb2ee8f264d in TStreamerInfoActions::GenericReadAction (buf=…, addr=0x2a2d540, config=0x2890420) at /opt/root/from-git/io/io/src/TStreamerInfoActions.cxx:167 #15 0x00007fb2ee88a96d in TStreamerInfoActions::TConfiguredAction::operator() (this=0x28904b0, buffer=…, object=0x2a2d540) at include/TStreamerInfoActions.h:111 #16 0x00007fb2ee888a36 in TBufferFile::ApplySequence (this=0x2897710, sequence=…, obj=0x2a2d540) at /opt/root/from-git/io/io/src/TBufferFile.cxx:3886 #17 0x00007fb2ee888514 in TBufferFile::ReadClassBuffer (this=0x2897710, cl=0x28884d0, pointer=0x2a2d540, onFileClass=0x0) at /opt/root/from-git/io/io/src/TBufferFile.cxx:3806 #18 0x00007fb2e8a83593 in storage::Streamer (this=0x2a2d540/build/buildd/gdb-7.7/gdb/stack.c:612: internal-error: print\_frame\_args: Assertion `nsym != NULL’ failed.

I’m attaching a small script which (compiled with root) demonstrates the problem. We are using root 5.34.20. Do you have any ideas what we might be doing wrong? Thank you very much in advance for your help!

Regards,  
e\_dude  
[breakingExample.C](https://root-forum.cern.ch/uploads/default/original/2X/b/bd9ce6e404c52a158af08aaf0a014e73362af3f5.C) (1.34 KB)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [September 3, 2014, 8:14pm UTC](https://root-forum.cern.ch/t/ttree-as-member-variable/18147/2 "2014-09-03T20:14:01Z")

</div>

.  
[breakingExample.C](https://root-forum.cern.ch/uploads/default/original/2X/1/1a999ed83a513eea65b1c3c7e3925645ab33509e.C) (1.71 KB)

---

<div class="post-metadata">

**Author:** ![explorer\_dude](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e5b9ba/32.png) [@explorer\_dude](https://root-forum.cern.ch/u/explorer_dude)\
**Post date:** [September 10, 2014, 9:58am UTC](https://root-forum.cern.ch/t/ttree-as-member-variable/18147/3 "2014-09-10T09:58:02Z")

</div>

Thank you, that works!
