Skip to content

Incorrect writing of jagged arrays into a TTree #1490

@vpec0

Description

@vpec0

When writing a jagged array into a TTree in an output ROOT file, if the array is larger than the TBasket, segmentation violation occurs when attempting to read the data in a ROOT session. UpRoot stores incorrect number of baskets used which possibly leads to the issue in ROOT.

Simple example:

of=ur.recreate('test.root')
of['tree']={'wfm':ak.from_regular(ak.Array(np.arange(32000*5*6,dtype='float').reshape(32000,5,6)),axis=-2)}
of['tree'].num_baskets # this is equal to 1
of.close()

After opening in ROOT (note the size of the basket and number of baskets for branch wfm vs the size of the branch):

$ root test.root
root [0] 
Attaching file test.root as _file0...
(TFile *) 0x7f9e8df4a730
root [1] tree->Print()
******************************************************************************
*Tree    :tree      :                                                        *
*Entries :    32000 : Total =         7937482 bytes  File  Size =    1410225 *
*        :          : Tree compression factor =   5.63                       *
******************************************************************************
*Br    0 :nwfm      : nwfm/I                                                 *
*Entries :    32000 : Total  Size=     128552 bytes  File Size  =        729 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression= 175.68     *
*............................................................................*
*Br    1 :wfm       : wfm[nwfm][6]/D                                         *
*Entries :    32000 : Total  Size=    7808656 bytes  File Size  =    1408155 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   5.54     *
*............................................................................*
root [2] tree->Draw("wfm")
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
Warning in <TBasket::ReadBasketBuffers>: basket:wfm has fNevBuf=32000 but fEntryOffset=0, pos=22484, len=7808078, fNbytes=1408155, fObjlen=7808008, trying to repair

 *** Break *** segmentation violation
...

I note here that if the stored array is not jagged, ROOT gives no segmentation violation even though the size of the branch is larger than a single basket and the number of baskets for the branch is still 1.

Metadata

Metadata

Assignees

Labels

bug (unverified)The problem described would be a bug, but needs to be triaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions