Pointers truncated in ROOT TSelector

109 views Asked by At

I'm using the scientific framework ROOT, so I'll provide some specifics about what I'm doing with that, but if anyone has any general ideas about what could cause this perhaps I can go into the source code and figure out what is happening, since I know not a ton of people have used ROOT.

I'm processing a TTree (ROOT data structure) using T.Process(). Basically, T.Process uses a class called objdef to analyze the data in the TTree. It loops over data in the TTree and fills vectors which will be output as a new TTree (I could go into more specifics if asked, but I figure it's better to state my general question than try to explain the entire ROOT framework in this question).

Pointers to the output vectors are declared in the objdef class definition. For most of the samples I run on, the entire system works great. But for some samples, the pointers sometimes appear to be truncated (?), causing seg faults. Here is an example:

Some pointers declared in the objdef declaration are:

std::vector<double>   *ele_pt;
std::vector<float>   *ele_charge;
std::vector<double>   *ele_eta;

when I run T.Process(), the pointers come out to be, for example:

ele_pt: 0x2ec45a0                                                                                                                                                                                                 
ele_charge: 0x2ec5840                                                                                                                                                                                             
ele_eta: 0x2d89 

What the heck is up with the third pointer! which pointer gets truncated seems to be random during each run of the code.

I wish I could be more specific, perhaps some pointed questions from SO could help me determine what's happening. Or, if anyone knows general things that could cause pointer truncation like this, I would love to hear it.

UPDATE

When I do sizeof on a bad pointer, it returns 8.

UPDATE 2

Evidently, some of the pointers were initialized to random values (or never initialized to zero?) before any memory was actually allocated, and then no memory was allocated to them. I suspect some bug deep in the ROOT framework (specifically Cint), but I've found a workaround - to just explicitly set all of the pointers to 0 and thus force ROOT to allocate them memory and give them a memory address. It is working now. It appears that perhaps the pointers weren't actually truncated--instead, they were just a small value. They never had a real memory address so they couldn't have been truncated in the first place.

0

There are 0 answers