Runtime crash when using vector<vector<int> > fr

Hi,

I have a macro created with MakeClass to read a TTree. In this tree, one variable is a vector<vector >. It is properly filled as I could verify using Scan. In order to read it, I have the following test code (the pointer to the variable being declared in the header file):

#include "Jpsi.h"
#include <vector>
#include <iostream>

void Jpsi::Loop()
{
gROOT->LoadMacro("VectorVectorDict.h+");
FILE *fp;
fp = fopen("Jpsi_out.txt","w");

fprintf(fp,"Electron PID= %d\n",(*elec_PID)[0][0]);

fclose(fp);
}

As the real (more complete) code involves some STL objects, I have to compile it with ACLIC. When I do so, it compiles just fine, but crashes when running it:

 *** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library "/lib64/tls/libthread_db.so.1".
Attaching to program: /proc/10000/exe, process 10000
(no debugging symbols found)...done.
(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
[New Thread 4147276000 (LWP 10000)]
0xffffe405 in __kernel_vsyscall ()
#1  0x00ad0f13 in __waitpid_nocancel () from /lib/tls/libc.so.6
#2  0x00a7a7b9 in do_system () from /lib/tls/libc.so.6
#3  0x00bad98d in system () from /lib/tls/libpthread.so.0
#4  0xf7b91adf in TUnixSystem::Exec ()
   from /atlas/software/releases/14.2.10_i686slc4/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libCore.so
#5  0xf7b974ed in TUnixSystem::StackTrace ()
   from /atlas/software/releases/14.2.10_i686slc4/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libCore.so
#6  0xf7b941aa in TUnixSystem::DispatchSignals ()
   from /atlas/software/releases/14.2.10_i686slc4/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libCore.so
#7  0xf7b94238 in SigHandler ()
   from /atlas/software/releases/14.2.10_i686slc4/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libCore.so
#8  0xf7b93485 in sighandler ()
   from /atlas/software/releases/14.2.10_i686slc4/sw/lcg/external/root/5.18.00d/slc4_ia32_gcc34/root/lib/libCore.so
#9  <signal handler called>
Couldn't recognize signal trampoline.
Root > 

What I am doing wrong here?

Also, here is VectorVectorDict.h:

#include <vector>

#ifdef __CINT__
#pragma link C++ class vector< vector <int> >;
#endif

template class vector< vector <int> >;

Thanks in advance,

Andrée

HI,

MakeClass does not really support nested vector. Try MakeProxy instead.

Cheers,
Philippe

In fact, I actually ‘solved’ my problem (or avoid it!) by making this vector<vector > a vector<vector > and the loading of the macro was suddenly enough to make it to work! What I did in my original attempt was basically loading a similar macro (that I used in PyROOT previously for vector<vector >) and modifying it to accept vector<vector >. This didn’t seem to work out.

Still, out of curiosity, why is it that ROOT can only read vector<vector > and not of any other type?

[quote]Still, out of curiosity, why is it that ROOT can only read vector<vector > and not of any other type?[/quote]I am not sure (not enough information on your actual case) but most likely there is a buffer overrun that lead to random behavior which sometimes works … and/or the dictionary for vector<vector > exist while vector<vector > does not (or vice et versa)

Cheers,
Philippe.[/u]