Seg Fault & Interpreter Crash Accessing Array Branch

Hi, I am getting a seg fault & interpreter crash when trying to access an element of a branch of the TTree when the branch was created as a fixed-size C++ array.

Here is the transcript of a minimal example that causes the crash:

jfcaron@dhcp-128-189-73-131:~/Projects/Proto2BeamTest2$ ipython
Python 2.7.6 (default, Nov 12 2013, 15:55:29) 
Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: %paste
from __future__ import division
import numpy, IPython
import sys
import ROOT,os
ROOT.gROOT.Macro( os.path.expanduser( '~/macros/rootlogon.C' ) )
## -- End pasted text --
*  ROOT v5.34/12  *

Out[1]: 1L

In [2]: f = ROOT.TFile("outfiles/20131207/run00110/Proto2Analyzed.root")
TClass::TClass:0: RuntimeWarning: no dictionary for class Output_Vars is available
TClass::TClass:0: RuntimeWarning: no dictionary for class Hot is available

In [3]: t = f.Get("Proto2Analyzed")

In [4]: t.Show(1)
======> EVENT:1
 output_vars     = (Output_Vars*)0x7ff539196800
 runnum          = 110
 Entry           = 1
 PID             = 13
 TOF_near        = 696.988
 TOF_far         = 781.85
 TOF_CP          = 829.725
 Track_x0        = 0.125485
 Track_Theta     = 1.57617
 N_Hots          = 6
 Track_Status    = 0
 Track_chi2      = 3.7027
 Track_ValidHots = 6
 Track_ProbChi2  = 0.447734
 N_Layers        = 7
 Layer_Occupancy[8] = 3 , 2 , 2 , 3 , 2 , 3 , 2 , 2 

 ACellDistanceFromWire = 0.121721
 ACellSignedDistance = 0.121721
 ACellDoca       = 0.291513
 ACell           = 12
 ACellPresent    = 1
 t0[28]          = -1 , -1 , 428 , 0 , -1 , 
                    167 , 0 , 0 , 0 , 403 , 
                    -1 , -1 , 270 , -1 , 0 , 
                    -1 , 408 , 0 , -1 , 198 

 x0[28]          = nan , nan , 0.619156 , 0 , nan , 
                    nan , 0 , 0 , 0 , 0.569839 , 
                    nan , nan , 0.291513 , nan , 0 , 
                    nan , 0.577877 , 0 , nan , 0.107859 

 dx0[28]         = nan , nan , 0.0306413 , 0 , nan , 
                    nan , 0 , 0 , 0.0251815 , 0.0171783 , 
                    nan , nan , 0.0109236 , nan , 0 , 
                    nan , 0.0194675 , 0 , nan , 0.0216949 

 arrival_times[28] = -0.17024 , -0.168189 , 0.26019 , 0 , -0.167719 , 
                    0.00072 , 0 , 0 , 0 , 0.234597 , 
                    -0.171083 , -0.170108 , 0.10168 , -0.169829 , 0 , 
                    -0.170684 , 0.238618 , 0 , -0.168194 , 0.029986 

 baselines[28]   = 157.901 , 187.911 , 213.257 , 0 , 170.059 , 
                    146.04 , 0 , 0 , 0 , 105.792 , 
                    102.297 , 142.495 , 157.95 , 122.465 , 0 , 
                    115.287 , 145.871 , 0 , 183.109 , 157.01 

 RMSes[28]       = 13.2534 , 12.7474 , 10.7709 , 0 , 13.1735 , 
                    10.5942 , 0 , 0 , 0 , 12.4768 , 
                    11.0234 , 13.0632 , 14.992 , 11.5772 , 0 , 
                    9.047 , 10.9052 , 0 , 11.0022 , 8.80312 

 signal_maxes[28] = 241 , 281 , 1250 , 0 , 253 , 
                    621 , 0 , 0 , 0 , 949 , 
                    193 , 221 , 625 , 217 , 0 , 
                    191 , 559 , 0 , 262 , 1105 

 signal_sums[28] = 158174 , 188327 , 269273 , 0 , 174558 , 
                    169779 , 0 , 0 , 0 , 187280 , 
                    102658 , 142291 , 191026 , 124073 , 0 , 
                    116588 , 195014 , 0 , 185837 , 189605 

 track_hots      = (map<int,Hot>*)0x7ff53cd064a0

In [5]: t.GetEntry(1)
Out[5]: 2220

In [6]: t.t0
Out[6]: <read-write buffer ptr 0xbff0000000000000, size 28 at 0x109adccf0>

In [7]: t.t0[0]

 *** Break *** segmentation violation



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

Thread 3 (process 61436):
#0  0x00007fff928abbca in __psynch_cvwait ()
#1  0x00007fff8a753274 in _pthread_cond_wait ()
#2  0x0000000108dc2541 in PyThread_acquire_lock ()
#3  0x0000000108d8997d in PyEval_RestoreThread ()
#4  0x00000001090f8a40 in time_sleep ()
#5  0x0000000108d8cb17 in PyEval_EvalFrameEx ()
#6  0x0000000108d8a416 in PyEval_EvalCodeEx ()
#7  0x0000000108d1f07b in function_call ()
#8  0x0000000108cfb521 in PyObject_Call ()
#9  0x0000000108d8ef76 in PyEval_EvalFrameEx ()
#10 0x0000000108d919a2 in fast_function ()
#11 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#12 0x0000000108d919a2 in fast_function ()
#13 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#14 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#15 0x0000000108d1f07b in function_call ()
#16 0x0000000108cfb521 in PyObject_Call ()
#17 0x0000000108d07196 in instancemethod_call ()
#18 0x0000000108cfb521 in PyObject_Call ()
#19 0x0000000108d911b8 in PyEval_CallObjectWithKeywords ()
#20 0x0000000108dc6b46 in t_bootstrap ()
#21 0x00007fff8a74f8bf in _pthread_start ()
#22 0x00007fff8a752b75 in thread_start ()

Thread 2 (process 61436):
#0  0x00007fff928abbca in __psynch_cvwait ()
#1  0x00007fff8a753274 in _pthread_cond_wait ()
#2  0x0000000108dc2541 in PyThread_acquire_lock ()
#3  0x0000000108d8997d in PyEval_RestoreThread ()
#4  0x0000000108dc6f24 in lock_PyThread_acquire_lock ()
#5  0x0000000108d8cb17 in PyEval_EvalFrameEx ()
#6  0x0000000108d8a416 in PyEval_EvalCodeEx ()
#7  0x0000000108d91a0d in fast_function ()
#8  0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#9  0x0000000108d8a416 in PyEval_EvalCodeEx ()
#10 0x0000000108d91a0d in fast_function ()
#11 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#12 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#13 0x0000000108d1f07b in function_call ()
#14 0x0000000108cfb521 in PyObject_Call ()
#15 0x0000000108d8ef76 in PyEval_EvalFrameEx ()
#16 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#17 0x0000000108d91a0d in fast_function ()
#18 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#19 0x0000000108d919a2 in fast_function ()
#20 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#21 0x0000000108d919a2 in fast_function ()
#22 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#23 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#24 0x0000000108d1f07b in function_call ()
#25 0x0000000108cfb521 in PyObject_Call ()
#26 0x0000000108d07196 in instancemethod_call ()
#27 0x0000000108cfb521 in PyObject_Call ()
#28 0x0000000108d911b8 in PyEval_CallObjectWithKeywords ()
#29 0x0000000108dc6b46 in t_bootstrap ()
#30 0x00007fff8a74f8bf in _pthread_start ()
#31 0x00007fff8a752b75 in thread_start ()

Thread 1 (process 61436):
#0  0x00007fff928ac168 in wait4 ()
#1  0x00007fff8a7055f5 in system ()
#2  0x000000010ae9fe19 in TUnixSystem::StackTrace ()
#3  0x000000010ae9d984 in TUnixSystem::DispatchSignals ()
#4  <signal handler called>
#5  0x000000010a6c0fd5 in (anonymous namespace)::Double_buffer_subscript ()
#6  0x0000000108d8d7eb in PyEval_EvalFrameEx ()
#7  0x0000000108d8a416 in PyEval_EvalCodeEx ()
#8  0x0000000108d8c0e6 in PyEval_EvalFrameEx ()
#9  0x0000000108d8a416 in PyEval_EvalCodeEx ()
#10 0x0000000108d91a0d in fast_function ()
#11 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#12 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#13 0x0000000108d91a0d in fast_function ()
#14 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#15 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#16 0x0000000108d91a0d in fast_function ()
#17 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#18 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#19 0x0000000108d91a0d in fast_function ()
#20 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#21 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#22 0x0000000108d91a0d in fast_function ()
#23 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#24 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#25 0x0000000108d91a0d in fast_function ()
#26 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#27 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#28 0x0000000108d1f07b in function_call ()
#29 0x0000000108cfb521 in PyObject_Call ()
#30 0x0000000108d8ef76 in PyEval_EvalFrameEx ()
#31 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#32 0x0000000108d91a0d in fast_function ()
#33 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#34 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#35 0x0000000108d89c46 in PyEval_EvalCode ()
#36 0x0000000108db0d9e in PyRun_FileExFlags ()
#37 0x0000000108db0900 in PyRun_SimpleFileExFlags ()
#38 0x0000000108dc47a8 in Py_Main ()
#39 0x0000000108ce7f24 in _mh_execute_header ()
===========================================================


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  0x000000010a6c0fd5 in (anonymous namespace)::Double_buffer_subscript ()
#6  0x0000000108d8d7eb in PyEval_EvalFrameEx ()
#7  0x0000000108d8a416 in PyEval_EvalCodeEx ()
#8  0x0000000108d8c0e6 in PyEval_EvalFrameEx ()
#9  0x0000000108d8a416 in PyEval_EvalCodeEx ()
#10 0x0000000108d91a0d in fast_function ()
#11 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#12 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#13 0x0000000108d91a0d in fast_function ()
#14 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#15 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#16 0x0000000108d91a0d in fast_function ()
#17 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#18 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#19 0x0000000108d91a0d in fast_function ()
#20 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#21 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#22 0x0000000108d91a0d in fast_function ()
#23 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#24 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#25 0x0000000108d91a0d in fast_function ()
#26 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#27 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#28 0x0000000108d1f07b in function_call ()
#29 0x0000000108cfb521 in PyObject_Call ()
#30 0x0000000108d8ef76 in PyEval_EvalFrameEx ()
#31 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#32 0x0000000108d91a0d in fast_function ()
#33 0x0000000108d8cbb8 in PyEval_EvalFrameEx ()
#34 0x0000000108d8a416 in PyEval_EvalCodeEx ()
#35 0x0000000108d89c46 in PyEval_EvalCode ()
#36 0x0000000108db0d9e in PyRun_FileExFlags ()
#37 0x0000000108db0900 in PyRun_SimpleFileExFlags ()
#38 0x0000000108dc47a8 in Py_Main ()
#39 0x0000000108ce7f24 in _mh_execute_header ()
===========================================================

This didn’t happen before when I used std::vector branches. Is there some inherent problem with C++ arrays as branches? I know the arrays don’t have length information, but I figured since they are fixed-size (until we build another prototype detector), that it would work fine. Is my TTree malformed? Keep in mind that I can make histograms and such just fine using TTree::Draw, it’s just accessing the branch pythonically that doesn’t work.

I can provide the .root file if needed, but it’s 66 mb, so I doubt the forum would let me upload it. The code that creates the actual TTree and TFile is located here:

bazaar.launchpad.net/~jfcaron/+j … :/MydaqT.C

Relevant line numbers are ~93, ~198, ~241

Thanks for any help,
Jean-François

Jean-François,

sorry for taking a long time to reply. Fix (and regression test) are in.

Cheers,
Wim