Segmentation violation on getting value in a Branch

Hi,

I have a following tree, with the following branches:

root [7] tree1->GetListOfBranches()->Print() *............................................................................* *Br 2 :Event : UInt_t event number * *Entries : 957 : Total Size= 76605066 bytes File Size = 400849 * *Baskets : 173 : Basket Size= 2589184 bytes Compression= 191.10 * *............................................................................*

However, if I try to get the content inside the TBranch with the following commands:

root [8] UInt_t event
root [9] tree->SetBranchAddress("TWOfflinePulsesHLC.Event", &event)
(const Int_t)0
root [10] tree->GetEntry(5)


 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007fd960601c8e in waitpid () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007fd96058729e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007fd9614c7af7 in TUnixSystem::StackTrace() () from /usr/local/root5.34/lib/root/libCore.so.5.34
#3  0x00007fd9614ca3d3 in TUnixSystem::DispatchSignals(ESignals) () from /usr/local/root5.34/lib/root/libCore.so.5.34
#4  <signal handler called>
#5  0x00007fd961c456a2 in ?? () from /lib64/ld-linux-x86-64.so.2
#6  0x00007fd961c4c235 in ?? () from /lib64/ld-linux-x86-64.so.2
#7  0x00007fd96141c8cd in TObject::ClassName() const () from /usr/local/root5.34/lib/root/libCore.so.5.34
#8  0x00007fd96141cea5 in TObject::DoError(int, char const*, char const*, __va_list_tag*) const () from /usr/local/root5.34/lib/root/libCore.so.5.34
#9  0x00007fd96141cd74 in TObject::Error(char const*, char const*, ...) const () from /usr/local/root5.34/lib/root/libCore.so.5.34
#10 0x00007fd95d914abf in ?? ()
#11 0x0000000001106db0 in ?? ()
#12 0x0000000000000000 in ?? ()
===========================================================

I usually have this error because of wrong type of my variable I try to load from the tree, but I checked this again and again (and copied it here) so I’m sure the type is indeed UInt_t. Does anyone know any other possibility why I have this error?

Thanks!

Edit: I should mention there are ~900 entries in the tree, so it’s possible to get entry 5 just before the crash.

Can you, please attach a root file with a minimal tree to reproduce your problem?
I guess you have a type error and ‘event’ should have a different type, not UInt_t.

One more thing (not really needed in your case with a simple ttree-related problem): whenever you attach a stack trace, it’s not a bad idea to build ROOT with debug symbols (–build=debug), since lines like:

0x12342343223423 Oh shi…
0x2343243244423432 blah-blah()
0x234234223423423 ku-ku()
0x234234234324432423 ko-ko()

are surprisingly useless and non-informative (of course, if you can reconfigure/rebuild ROOT on your machine) :wink:

[quote=“tpochep”]Can you, please attach a root file with a minimal tree to reproduce your problem?
I guess you have a type error and ‘event’ should have a different type, not UInt_t.

One more thing (not really needed in your case with a simple ttree-related problem): whenever you attach a stack trace, it’s not a bad idea to build ROOT with debug symbols (–build=debug), since lines like:

0x12342343223423 Oh shi…
0x2343243244423432 blah-blah()
0x234234223423423 ku-ku()
0x234234234324432423 ko-ko()

are surprisingly useless and non-informative (of course, if you can reconfigure/rebuild ROOT on your machine) :wink:[/quote]

I’m not sure how I can get the minimal tree. However, how is it possible that Event is a different type, if ROOT itself says it’s a UInt_t? If I try with a Int_t, I get by the way the following:

Error in <TTree::SetBranchAddress>: The pointer type given "Int_t" (3) does not correspond to the type needed "UInt_t" (13) by the branch: Event

P.S. I have no clue how to reconfigure my system or how to use the debug options inside root (I usually program in QtCreator but I’m unable to compile with it because of linking errors, so I’d be very grateful if you could redirect my to a beginner guide of these things!)

[quote=“japdhaes”]
I’m not sure how I can get the minimal tree. [/quote]

By a minimal tree I mean any tree/data to reproduce a segmentation violation you have, if a root file is small enough to attach it here.

[quote=“tpochep”][quote=“japdhaes”]
I’m not sure how I can get the minimal tree. [/quote]

By a minimal tree I mean any tree/data to reproduce a segmentation violation you have, if a root file is small enough to attach it here.[/quote]

Hi I wanted to let you know that I found the reason for the segmentation fault. It’s some weird TTree structure with several trees being linked to each other as friends, and when I use the value in the (possible) original tree, I don’t get the segmentation fault anymore.

Thanks anyway for the help!

Wow! Ok, great that you fixed it yourself, really great, I can imagine how we could spend a lot of your and my time if I tried to help (I know nothing about tree friends and do not want to know :slight_smile: ).

Thanks for your reply!