GetBranch crashes.. memory limit?

Dear Root experts,

I am trying to read back several branches of a root file through a c++ code. I use:
TBranch *branch1 = T->GetBranch(“polarity”);
T->SetBranchStatus(“polarity”,1);
T->SetBranchAddress(“polarity”,&pol);

and so on…
Everything works fine, however, after the 17th branch, as soon as I try to open the 18th and the last (not the last in the tree, but the last one that I need to open), the execution crashes with a segmentation fault:

*** Break *** segmentation violation
Using host libthread_db library “/lib/libthread_db.so.1”.
Attaching to program: /proc/13079/exe, process 13079
warning: Missing the separate debug info file: /usr/lib/debug/.build-id/db/a292aff9720bfc3f25c53fa8e469168460a894.debug
done.
warning: Missing the separate debug info file: /usr/lib/debug/.build-id/92/8ab51a53627c59877a85dd9afecc1619ca866c.debug
done.

:
:
:
warning: Missing the separate debug info file: /usr/lib/debug/.build-id/a7/eabb854181ef5ff0c22b78c3e5048c64a2ebb8.debug
done.
warning: Missing the separate debug info file: /usr/lib/debug/.build-id/fd/ed9da1642b1242f8fa10f35481391994499c14.debug
done.
warning: Missing the separate debug info file: /usr/lib/debug/.build-id/05/21ec3b01f5c03599572e0d2598fdc0da7e21cb.debug
done.
0x00110402 in __kernel_vsyscall ()
#1 0x01866953 in _waitpid_nocancel () from /lib/libc.so.6
#2 0x0180abab in do_system () from /lib/libc.so.6
#3 0x002f722b in TUnixSystem::Exec () from /apps/root/PRO/root/lib/libCore.so.5.22
#4 0x002fcebf in TUnixSystem::StackTrace () from /apps/root/PRO/root/lib/libCore.so.5.22
#5 0x002f98be in TUnixSystem::DispatchSignals () from /apps/root/PRO/root/lib/libCore.so.5.22
#6 0x002f994c in SigHandler () from /apps/root/PRO/root/lib/libCore.so.5.22
#7 0x002f8bc9 in sighandler () from /apps/root/PRO/root/lib/libCore.so.5.22
#8
#9 0x018453d7 in memset () from /lib/libc.so.6
#10 0x06c0be5a in mysql_init () from /usr/lib/mysql/libmysqlclient.so.15
#11 0x080c379f in calib_connect ()
#12 0x080c1b61 in calib_get_float ()
#13 0x080c0df1 in map_get_float ()
#14 0x080a24cc in make_SCG_banks ()
#15 0x080a3435 in initialize_tof_gc
()
#16 0x080a3483 in initialize_tof_gc ()
#17 0x0805f238 in Jsc_geom (this=0xe654298, runno=52897) at Jsc_geom.cpp:18
#18 0x08057505 in main ()
The program is running. Quit anyway (and detach it)? (y or n) [answered Y; input not from terminal]
Detaching from program: /proc/13079/exe, process 13079

This doesn’t make sense unless there is a memory limit to GetBranch. If so, how can I get around this problem? :open_mouth:

Thanks in advance.

Best regards,
Maryam

Hi Maryam,

GetBranch does not allocate any memory, it simply search in a list and return an (already) existing pointer.

Cheers,
Philippe.

Hi Philippe,

Thanks for your reply. It turns out that this error message comes up also, when I try to add a new branch to the same tree and fill it:
TBranch *newBranch1 = T->Branch(“flag”,&flag,“flag/F”);
newBranch1->Fill(); --> crashes here

So it it not just the GetBranch! I’m not sure what’s going on. :confused:

I really really appreciate any ideas or suggestions.

Best regards,
Maryam

Hi Maryam,

I recommend that you try valgrind; I suspect that an unrelated memory error is causing those problems.

Cheers,
Philippe.

Thanks for your recommendation Philippe,
Unfortunately valgrind does not support my version of macOS which is 10.4.11. :frowning:

Maryam

[quote]TBranch *newBranch1 = T->Branch(“flag”,&flag,“flag/F”);
newBranch1->Fill(); --> crashes here [/quote]A priori this only can break if ‘flag’, or T are pointing to already deleted memory.

If you provide a complete running example, I will take a look?

Cheers,
Philippe.