Segmentation violation when working with trees

Hi,
I’m running a newly-compiled version of ROOT (5.30/04) on OSX Lion and I’m getting a segmentation violation when trying to work with TTrees.

[code]In [2]: import ROOT

In [3]: f = ROOT.TFile(“Results286252.root”)

In [4]: t = f.Get(“FitResults”)

In [5]: t.Scan()

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

Thread 7 (process 61214):
#0 0x00007fff80f42bca in __psynch_cvwait ()
#1 0x00007fff86b03274 in _pthread_cond_wait ()
#2 0x0000000100104d26 in PyThread_acquire_lock ()
#3 0x00000001000c39ea in PyEval_RestoreThread ()
#4 0x0000000100791f7e in time_sleep ()
#5 0x00000001000cabb1 in PyEval_EvalFrameEx ()
#6 0x00000001000cca15 in PyEval_EvalCodeEx ()
#7 0x000000010003fce2 in function_call ()
#8 0x000000010000d002 in PyObject_Call ()
#9 0x00000001000c5fa6 in PyEval_EvalFrameEx ()
#10 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#11 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#12 0x00000001000cca15 in PyEval_EvalCodeEx ()
#13 0x000000010003fce2 in function_call ()
#14 0x000000010000d002 in PyObject_Call ()
#15 0x000000010001f7c1 in instancemethod_call ()
#16 0x000000010000d002 in PyObject_Call ()
#17 0x00000001000c3d27 in PyEval_CallObjectWithKeywords ()
#18 0x000000010010a383 in t_bootstrap ()
#19 0x00007fff86aff8bf in _pthread_start ()
#20 0x00007fff86b02b75 in thread_start ()

Thread 6 (process 61214):
#0 0x00007fff80f43192 in __workq_kernreturn ()
#1 0x00007fff86b01594 in _pthread_wqthread ()
#2 0x00007fff86b02b85 in start_wqthread ()

Thread 5 (process 61214):
#0 0x00007fff80f43192 in __workq_kernreturn ()
#1 0x00007fff86b01594 in _pthread_wqthread ()
#2 0x00007fff86b02b85 in start_wqthread ()

Thread 4 (process 61214):
#0 0x00007fff80f42df2 in select$DARWIN_EXTSN ()
#1 0x00007fff88a62f9b in __CFSocketManager ()
#2 0x00007fff86aff8bf in _pthread_start ()
#3 0x00007fff86b02b75 in thread_start ()

Thread 3 (process 61214):
#0 0x00007fff80f437e6 in kevent ()
#1 0x00007fff8a0945be in _dispatch_mgr_invoke ()
#2 0x00007fff8a09314e in _dispatch_mgr_thread ()

Thread 2 (process 61214):
#0 0x00007fff80f42bca in __psynch_cvwait ()
#1 0x00007fff86b03274 in _pthread_cond_wait ()
#2 0x0000000100104d26 in PyThread_acquire_lock ()
#3 0x00000001001099c5 in lock_PyThread_acquire_lock ()
#4 0x00000001000cabb1 in PyEval_EvalFrameEx ()
#5 0x00000001000cca15 in PyEval_EvalCodeEx ()
#6 0x00000001000cab0f in PyEval_EvalFrameEx ()
#7 0x00000001000cca15 in PyEval_EvalCodeEx ()
#8 0x00000001000cab0f in PyEval_EvalFrameEx ()
#9 0x00000001000cca15 in PyEval_EvalCodeEx ()
#10 0x00000001000cab0f in PyEval_EvalFrameEx ()
#11 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#12 0x00000001000cca15 in PyEval_EvalCodeEx ()
#13 0x000000010003fce2 in function_call ()
#14 0x000000010000d002 in PyObject_Call ()
#15 0x000000010001f7c1 in instancemethod_call ()
#16 0x000000010000d002 in PyObject_Call ()
#17 0x00000001000c3d27 in PyEval_CallObjectWithKeywords ()
#18 0x000000010010a383 in t_bootstrap ()
#19 0x00007fff86aff8bf in _pthread_start ()
#20 0x00007fff86b02b75 in thread_start ()

Thread 1 (process 61214):
#0 0x00007fff80f43168 in wait4 ()
#1 0x00007fff86ab55f5 in system ()
#2 0x000000010b69337c in TUnixSystem::StackTrace ()
#3 0x000000010b69623a in TUnixSystem::DispatchSignals ()
#4
#5 0x000000010b518d34 in PyROOT::TTreeGetAttr ()
#6 0x000000010b526f6e in PyROOT::im_call ()
#7 0x000000010000d002 in PyObject_Call ()
#8 0x000000010000d24c in PyObject_CallFunctionObjArgs ()
#9 0x0000000100086a5b in slot_tp_getattr_hook ()
#10 0x00000001000bf30a in builtin_getattr ()
#11 0x00000001000cabb1 in PyEval_EvalFrameEx ()
#12 0x00000001000cca15 in PyEval_EvalCodeEx ()
#13 0x00000001000cab0f in PyEval_EvalFrameEx ()
#14 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#15 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#16 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#17 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#18 0x00000001000cca15 in PyEval_EvalCodeEx ()
#19 0x00000001000cab0f in PyEval_EvalFrameEx ()
#20 0x00000001000cca15 in PyEval_EvalCodeEx ()
#21 0x00000001000cab0f in PyEval_EvalFrameEx ()
#22 0x00000001000cca15 in PyEval_EvalCodeEx ()
#23 0x00000001000cab0f in PyEval_EvalFrameEx ()
#24 0x00000001000cca15 in PyEval_EvalCodeEx ()
#25 0x00000001000cab0f in PyEval_EvalFrameEx ()
#26 0x00000001000cca15 in PyEval_EvalCodeEx ()
#27 0x00000001000cab0f in PyEval_EvalFrameEx ()
#28 0x00000001000cca15 in PyEval_EvalCodeEx ()
#29 0x00000001000cab0f in PyEval_EvalFrameEx ()
#30 0x00000001000cca15 in PyEval_EvalCodeEx ()
#31 0x00000001000cab0f in PyEval_EvalFrameEx ()
#32 0x00000001000cca15 in PyEval_EvalCodeEx ()
#33 0x00000001000ccd16 in PyEval_EvalCode ()
#34 0x00000001000f11ee in PyRun_FileExFlags ()
#35 0x00000001000f2001 in PyRun_SimpleFileExFlags ()
#36 0x0000000100107c65 in Py_Main ()
#37 0x0000000100000f54 in start ()

The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug 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.

#5 0x000000010b518d34 in PyROOT::TTreeGetAttr ()
#6 0x000000010b526f6e in PyROOT::im_call ()
#7 0x000000010000d002 in PyObject_Call ()
#8 0x000000010000d24c in PyObject_CallFunctionObjArgs ()
#9 0x0000000100086a5b in slot_tp_getattr_hook ()
#10 0x00000001000bf30a in builtin_getattr ()
#11 0x00000001000cabb1 in PyEval_EvalFrameEx ()
#12 0x00000001000cca15 in PyEval_EvalCodeEx ()
#13 0x00000001000cab0f in PyEval_EvalFrameEx ()
#14 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#15 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#16 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#17 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#18 0x00000001000cca15 in PyEval_EvalCodeEx ()
#19 0x00000001000cab0f in PyEval_EvalFrameEx ()
#20 0x00000001000cca15 in PyEval_EvalCodeEx ()
#21 0x00000001000cab0f in PyEval_EvalFrameEx ()
#22 0x00000001000cca15 in PyEval_EvalCodeEx ()
#23 0x00000001000cab0f in PyEval_EvalFrameEx ()
#24 0x00000001000cca15 in PyEval_EvalCodeEx ()
#25 0x00000001000cab0f in PyEval_EvalFrameEx ()
#26 0x00000001000cca15 in PyEval_EvalCodeEx ()
#27 0x00000001000cab0f in PyEval_EvalFrameEx ()
#28 0x00000001000cca15 in PyEval_EvalCodeEx ()
#29 0x00000001000cab0f in PyEval_EvalFrameEx ()
#30 0x00000001000cca15 in PyEval_EvalCodeEx ()
#31 0x00000001000cab0f in PyEval_EvalFrameEx ()
#32 0x00000001000cca15 in PyEval_EvalCodeEx ()
#33 0x00000001000ccd16 in PyEval_EvalCode ()
#34 0x00000001000f11ee in PyRun_FileExFlags ()
#35 0x00000001000f2001 in PyRun_SimpleFileExFlags ()
#36 0x0000000100107c65 in Py_Main ()
#37 0x0000000100000f54 in start ()
===========================================================[/code]

I can work with the same file just fine in CINT, and in pyROOT when logged onto fnal, so I don’t think there’s anything wrong with the file. I get the same segmentation violation when trying to do anything else with the tree, such as GetEntry(2). I’d guess something might be compiled wrong? Any ideas?

Thanks,
Nic

Nic,

what is “FitResults”? I’m thinking along the lines that there is a dictionary available on the fnal system, but not on the system you’re using (that does not justify a crash, of course).

Cheers,
Wim

Sorry, FitResults is the name of the tree in the file.

Hi,

yes of course, should have seen that … I was mislead by the stack trace:

The above call happens when a branch is looked up on the tree as if it is a data member (the lookup on the python side fails then falls to getattr).

Because of that, the code above morphed into t.FitResults in my head.

Anyway, that does push the point that TTreeGetAttrl should never occur down from t.Scan(), as that call simply maps onto the C++ TTree::Scan() function directly, thus exists, and thus never sees getattr.

Could you check whether TTree.Scan exists (i.e. on the class) in your case?

Cheers,
Wim

It seems to exist.

[code]In [1]: import ROOT

In [2]: ROOT.TTree.Scan
Out[2]: <ROOT.MethodProxy at 0x101484c10>

In [3]: ROOT.TTree.Scan()

TypeError Traceback (most recent call last)
/Users/nic/ in ()
----> 1 ROOT.TTree.Scan()

TypeError: Long64_t TTree::Scan(const char* varexp = “”, const char* selection = “”, Option_t* option = “”, Long64_t nentries = 1000000000, Long64_t firstentry = 0) =>
unbound method TTree::Scan must be called with a TTree instance as first argument[/code]

Interestingly, doing

works.

Hi,

could you print ‘t’ and ‘type(t)’?

Thanks,
Wim

print t gives a segmentation violation:

[code]In [1]: import ROOT

In [2]: f = ROOT.TFile("Res
Results286252.root Results342269.root

In [2]: f = ROOT.TFile(“Results342269.root”)

In [3]: t = f.Get(“FitResults”)

In [4]: print t

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

Thread 3 (process 18066):
#0 0x00007fff80f42bca in __psynch_cvwait ()
#1 0x00007fff86b03274 in _pthread_cond_wait ()
#2 0x0000000100104d26 in PyThread_acquire_lock ()
#3 0x00000001000c39ea in PyEval_RestoreThread ()
#4 0x0000000100791f7e in time_sleep ()
#5 0x00000001000cabb1 in PyEval_EvalFrameEx ()
#6 0x00000001000cca15 in PyEval_EvalCodeEx ()
#7 0x000000010003fce2 in function_call ()
#8 0x000000010000d002 in PyObject_Call ()
#9 0x00000001000c5fa6 in PyEval_EvalFrameEx ()
#10 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#11 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#12 0x00000001000cca15 in PyEval_EvalCodeEx ()
#13 0x000000010003fce2 in function_call ()
#14 0x000000010000d002 in PyObject_Call ()
#15 0x000000010001f7c1 in instancemethod_call ()
#16 0x000000010000d002 in PyObject_Call ()
#17 0x00000001000c3d27 in PyEval_CallObjectWithKeywords ()
#18 0x000000010010a383 in t_bootstrap ()
#19 0x00007fff86aff8bf in _pthread_start ()
#20 0x00007fff86b02b75 in thread_start ()

Thread 2 (process 18066):
#0 0x00007fff80f42bca in __psynch_cvwait ()
#1 0x00007fff86b03274 in _pthread_cond_wait ()
#2 0x0000000100104d26 in PyThread_acquire_lock ()
#3 0x00000001000c39ea in PyEval_RestoreThread ()
#4 0x00000001001099d0 in lock_PyThread_acquire_lock ()
#5 0x00000001000cabb1 in PyEval_EvalFrameEx ()
#6 0x00000001000cca15 in PyEval_EvalCodeEx ()
#7 0x00000001000cab0f in PyEval_EvalFrameEx ()
#8 0x00000001000cca15 in PyEval_EvalCodeEx ()
#9 0x00000001000cab0f in PyEval_EvalFrameEx ()
#10 0x00000001000cca15 in PyEval_EvalCodeEx ()
#11 0x00000001000cab0f in PyEval_EvalFrameEx ()
#12 0x00000001000cb3f6 in PyEval_EvalFrameEx ()
#13 0x00000001000cca15 in PyEval_EvalCodeEx ()
#14 0x000000010003fce2 in function_call ()
#15 0x000000010000d002 in PyObject_Call ()
#16 0x000000010001f7c1 in instancemethod_call ()
#17 0x000000010000d002 in PyObject_Call ()
#18 0x00000001000c3d27 in PyEval_CallObjectWithKeywords ()
#19 0x000000010010a383 in t_bootstrap ()
#20 0x00007fff86aff8bf in _pthread_start ()
#21 0x00007fff86b02b75 in thread_start ()

Thread 1 (process 18066):
#0 0x00007fff80f43168 in wait4 ()
#1 0x00007fff86ab55f5 in system ()
#2 0x00000001040c931c in TUnixSystem::StackTrace ()
#3 0x00000001040cc1da in TUnixSystem::DispatchSignals ()
#4
#5 0x0000000101f2fd34 in PyROOT::TTreeGetAttr ()
#6 0x0000000101f3df6e in PyROOT::im_call ()
#7 0x000000010000d002 in PyObject_Call ()
#8 0x000000010000d24c in PyObject_CallFunctionObjArgs ()
#9 0x0000000100086a5b in slot_tp_getattr_hook ()
#10 0x000000010005cee9 in PyObject_HasAttr ()
#11 0x0000000101f2b867 in PyROOT::(anonymous namespace)::op_repr ()
#12 0x000000010005c60a in _PyObject_Str ()
#13 0x000000010005e7c8 in internal_print ()
#14 0x0000000100036971 in PyFile_WriteObject ()
#15 0x00000001000c8c17 in PyEval_EvalFrameEx ()
#16 0x00000001000cca15 in PyEval_EvalCodeEx ()
#17 0x00000001000cb218 in PyEval_EvalFrameEx ()
#18 0x00000001000cca15 in PyEval_EvalCodeEx ()
#19 0x00000001000cab0f in PyEval_EvalFrameEx ()
#20 0x00000001000cca15 in PyEval_EvalCodeEx ()
#21 0x00000001000cab0f in PyEval_EvalFrameEx ()
#22 0x00000001000cca15 in PyEval_EvalCodeEx ()
#23 0x00000001000cab0f in PyEval_EvalFrameEx ()
#24 0x00000001000cca15 in PyEval_EvalCodeEx ()
#25 0x00000001000cab0f in PyEval_EvalFrameEx ()
#26 0x00000001000cca15 in PyEval_EvalCodeEx ()
#27 0x00000001000cab0f in PyEval_EvalFrameEx ()
#28 0x00000001000cca15 in PyEval_EvalCodeEx ()
#29 0x00000001000cab0f in PyEval_EvalFrameEx ()
#30 0x00000001000cca15 in PyEval_EvalCodeEx ()
#31 0x00000001000cab0f in PyEval_EvalFrameEx ()
#32 0x00000001000cca15 in PyEval_EvalCodeEx ()
#33 0x00000001000ccd16 in PyEval_EvalCode ()
#34 0x00000001000f11ee in PyRun_FileExFlags ()
#35 0x00000001000f2001 in PyRun_SimpleFileExFlags ()
#36 0x0000000100107c65 in Py_Main ()
#37 0x0000000100000f54 in start ()

The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug 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.

#5 0x0000000101f2fd34 in PyROOT::TTreeGetAttr ()
#6 0x0000000101f3df6e in PyROOT::im_call ()
#7 0x000000010000d002 in PyObject_Call ()
#8 0x000000010000d24c in PyObject_CallFunctionObjArgs ()
#9 0x0000000100086a5b in slot_tp_getattr_hook ()
#10 0x000000010005cee9 in PyObject_HasAttr ()
#11 0x0000000101f2b867 in PyROOT::(anonymous namespace)::op_repr ()
#12 0x000000010005c60a in _PyObject_Str ()
#13 0x000000010005e7c8 in internal_print ()
#14 0x0000000100036971 in PyFile_WriteObject ()
#15 0x00000001000c8c17 in PyEval_EvalFrameEx ()
#16 0x00000001000cca15 in PyEval_EvalCodeEx ()
#17 0x00000001000cb218 in PyEval_EvalFrameEx ()
#18 0x00000001000cca15 in PyEval_EvalCodeEx ()
#19 0x00000001000cab0f in PyEval_EvalFrameEx ()
#20 0x00000001000cca15 in PyEval_EvalCodeEx ()
#21 0x00000001000cab0f in PyEval_EvalFrameEx ()
#22 0x00000001000cca15 in PyEval_EvalCodeEx ()
#23 0x00000001000cab0f in PyEval_EvalFrameEx ()
#24 0x00000001000cca15 in PyEval_EvalCodeEx ()
#25 0x00000001000cab0f in PyEval_EvalFrameEx ()
#26 0x00000001000cca15 in PyEval_EvalCodeEx ()
#27 0x00000001000cab0f in PyEval_EvalFrameEx ()
#28 0x00000001000cca15 in PyEval_EvalCodeEx ()
#29 0x00000001000cab0f in PyEval_EvalFrameEx ()
#30 0x00000001000cca15 in PyEval_EvalCodeEx ()
#31 0x00000001000cab0f in PyEval_EvalFrameEx ()
#32 0x00000001000cca15 in PyEval_EvalCodeEx ()
#33 0x00000001000ccd16 in PyEval_EvalCode ()
#34 0x00000001000f11ee in PyRun_FileExFlags ()
#35 0x00000001000f2001 in PyRun_SimpleFileExFlags ()
#36 0x0000000100107c65 in Py_Main ()
#37 0x0000000100000f54 in start ()
===========================================================[/code]

type(t) gives ROOT.TTree

Thanks,
Nic

Nic,

in retrospect, the first crash is not too odd, as repr on ROOT objects checks for the existence of the deref method (to implement smart-pointer functionality) and we’ve seen already that getattr on ‘t’ crashes it.

Still trying to collect data points to help with the guessing …

Finding out whether it’s a problem with the build, not with the file (i.e. missing dictionaries for this particular file), can probably be tested with these:

TTree().Scan() print TTree()
Cheers,
Wim

The first works, while the second gives a segmentation violation.

Nic,

then it must be a problem with the local build …

Since you did make the build yourself. :slight_smile: Can you make a debug build and run the debugger, or (probably quicker) modify bindings/pyroot/src/Pythonize.cxx and find the TTreeGetAttr() function, commenting out bits and pieces to get a clearer place where it fails? I have no access to a Lion box myself …

Given that the default-constructed TTree has no branches or leaves, the only thing I can think of is this failing:

  TTree* tree =
     (TTree*)self->ObjectIsA()->DynamicCast( TTree::Class(), self->GetObject() );

(Failing in the sense of returning a tree pointer that points to some wrong place; it’s checked for null.)

If so, it’d be a bug in ROOT/meta, though.

Cheers,
WIm

I think I solved the problem. There must have been some cruft laying around from an old build. When I deleted my ROOT install and rebuilt it, it worked fine.

Thanks for your help.

Nic