Re: CINT crashes when reading 2 objects with identical key from 2 different files

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Fri, 9 Dec 2011 14:58:33 +0100


Hi Thiemo,

Some members were uninitialized. As you know, you can read data from a TFile into an existing object (think "Event" in a TTree). And you can re-read, into the same object. Reading the old object, ROOT might have initialized the member TH2D* fBeamPdY_nocut by creating a histogram, and having fBeamPdY_nocut point to it. Which means when reading the next object it first needs to delete the histogram fBeamPdY_nocut points to.

You happen to not initialize fBeamPdY_nocut in the constructor, which means ROOT has no way of knowing that this was in fact not allocated. Simply add initializers for the missing members.

This is what I used to scan through your list of members: $ grep -E '\*f[[:alnum:]_]+;' /build/tmp/Selector.h | sed -E 's,^.*\*(f[[:alnum:]_]+);.*$,\1,' |sort > Thiemo_vars.txt $ grep -E '^ *f[[:alnum:]_]+ *\(' /build/tmp/Selector.h | sed -E 's,^ *(f[[:alnum:]_]+) *\(.*$,\1,' |sort > Thiemo_init.txt $ diff -u0 Thiemo_vars.txt Thiemo_init.txt |less

"+" will be initializers for variables that are non-pointers (because Thiemo_vars.txt only contains pointer vars). "-" will be the ones you still need to initialize.

Let us know if that didn't fix it.

Cheers, Axel.

Thiemo Nagel wrote on 11/30/2011 06:18 PM:
> Dear ROOTers,
>
> I'd kindly ask for your help with some crashes that I'm observing with
> some of my code running with ROOT 5.30.03. I guess that the problem is
> on my side, but I can't figure out what is wrong.
>
> Starting point: I'm storing the output of my analysis in a customized
> "Selector" class which inherits from "MySelector" which inherits from
> TSelector. To determine some physical quantities, I'd like to divide
> the output of two analysis runs, which means that I'm trying to read two
> Selector objects from two different .root files. But this is already
> causing crashes. (I've tested that both selectors work well, when the
> files are opened individually. It's just when both are accessed in the
> same script that the problem occurs.)
>
> testpol.C is a minimal script which triggers my problem.
> prepareSelectors.C must be called beforehand in order to load all
> classes into CINT. (For some reason, interpreting the class fails.)
> I've also attached MySelector.h and Selector.h, in case that might be
> useful for diagnosis.
>
> Any help would be greatly appreciated!
>
> Cheers,
> Thiemo
>
> P.S.: Below is the output of one of the crashes:
>
> [0] mnemosyne:~/analysis/selector> root -n prepareSelectors.C testpol.C
> root [0]
> Processing prepareSelectors.C...
> 0.177548 s
> 0.215103 s
> 0.243131 s
> 0.269481 s
> 0.295701 s
> 0.323266 s
> 0.35179 s
> 0.379835 s
> 0.408063 s
> 0.449982 s
> Processing testpol.C...
> TFile** murd.root
> TFile* murd.root
> KEY: Selector Selector;1
> got Selector: 'murd'
> TFile** mumc.root
> TFile* mumc.root
> KEY: Selector Selector;1
>
> *** Break *** segmentation violation
>
>
>
> ===========================================================
> There was a crash.
> This is the entire stack trace of all threads:
> ===========================================================
> #0 0xb7779424 in __kernel_vsyscall ()
> #1 0xb65c9003 in __waitpid_nocancel ()
> at ../sysdeps/unix/syscall-template.S:82
> #2 0xb656ae63 in do_system (line=<value optimized out>)
> at ../sysdeps/posix/system.c:149
> #3 0xb66863bd in system (
> line=0xb909630 "/usr/local/root/root_v5.30.03/etc/gdb-backtrace.sh
> 3137 1>&2") at pt-system.c:29
> #4 0xb72203cd in TUnixSystem::Exec(char const*) ()
> from /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #5 0xb722716b in TUnixSystem::StackTrace() ()
> from /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #6 0xb72259af in TUnixSystem::DispatchSignals(ESignals) ()
> from /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #7 0xb7225abd in ?? () from
> /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #8 0xb721cdc2 in ?? () from
> /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #9 0xb724bffd in textinput::TerminalConfigUnix::HandleSignal(int) ()
> from /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #10 0xb724c3d6 in ?? () from
> /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #11 <signal handler called>
> #12 0xb5a46c1d in ?? () from
> /usr/local/root/root_v5.30.03/lib/libHist.so.5.30
> #13 0xb71e9c90 in TClass::Destructor(void*, bool) ()
> from /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #14 0xb626a2d9 in TBufferFile::ReadFastArray(void**, TClass const*, int,
> bool, TMemberStreamer*, TClass const*) ()
> from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #15 0xb632b687 in int TStreamerInfo::ReadBuffer<char**>(TBuffer&, char**
> const&, int, int, int, int) () from
> /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #16 0xb62ae1a9 in TStreamerInfoActions::GenericAction(TBuffer&, void*,
> TStreamerInfoActions::TConfiguration const*) ()
> from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #17 0xb626439c in
> TBufferFile::ReadSequence(TStreamerInfoActions::TActionSequence const&,
> void*) () from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #18 0xb626486b in TBufferFile::ReadClassBuffer(TClass const*, void*,
> TClass const*) () from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #19 0xb44d674e in Selector::Streamer(TBuffer&) ()
> from /tmp/tnagel/aclic_builddir/Selector_cc.so
> #20 0xb62a1afb in TKey::ReadObj() ()
> from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #21 0xb62751f1 in TDirectoryFile::Get(char const*) ()
> from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #22 0xb727159e in ?? () from
> /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #23 0xb6a7f0f7 in Cint::G__ExceptionWrapper(int (*)(G__value*, char
> const*, G__param*, int), G__value*, char*, G__param*, int) ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #24 0xb6b2e4cf in G__execute_call ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #25 0xb6b2f36a in G__call_cppfunc ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #26 0xb6b09991 in G__interpret_func ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #27 0xb6af61ec in G__getfunction ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #28 0xb6bf6524 in G__getstructmem(int, G__FastAllocString&, char*, int,
> char*, int*, G__var_array*, int) ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #29 0xb6beafc5 in G__getvariable ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #30 0xb6acfc18 in G__getitem ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #31 0xb6ad51ac in G__getexpr ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #32 0xb6af5694 in G__getfunction ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #33 0xb6ad028b in G__getitem ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #34 0xb6ad51ac in G__getexpr ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #35 0xb6af6a6f in G__getfunction ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #36 0xb6ad028b in G__getitem ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #37 0xb6ad51ac in G__getexpr ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #38 0xb6abf235 in G__define_var ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #39 0xb6b5bc9c in G__exec_statement ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #40 0xb6b0ac7e in G__interpret_func ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #41 0xb6af6251 in G__getfunction ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #42 0xb6ad028b in G__getitem ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #43 0xb6ad51ac in G__getexpr ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #44 0xb6adfe28 in G__calc_internal ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #45 0xb6b6e629 in G__process_cmd ()
> from /usr/local/root/root_v5.30.03/lib/libCint.so.5.30
> #46 0xb71de75b in TCint::ProcessLine(char const*,
> TInterpreter::EErrorCode*) ()
> from /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #47 0xb71dc111 in TCint::ProcessLineSynch(char const*,
> TInterpreter::EErrorCode*) () from
> /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #48 0xb71253bc in TApplication::ExecuteFile(char const*, int*, bool) ()
> from /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #49 0xb71256dc in TApplication::ProcessFile(char const*, int*, bool) ()
> from /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #50 0xb7122ae8 in TApplication::ProcessLine(char const*, bool, int*) ()
> from /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #51 0xb68069ca in TRint::Run(bool) ()
> from /usr/local/root/root_v5.30.03/lib/libRint.so.5.30
> #52 0x08048ebf in main ()
> ===========================================================
>
>
> 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.
> ===========================================================
> #12 0xb5a46c1d in ?? () from
> /usr/local/root/root_v5.30.03/lib/libHist.so.5.30
> #13 0xb71e9c90 in TClass::Destructor(void*, bool) ()
> from /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> #14 0xb626a2d9 in TBufferFile::ReadFastArray(void**, TClass const*, int,
> bool, TMemberStreamer*, TClass const*) ()
> from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #15 0xb632b687 in int TStreamerInfo::ReadBuffer<char**>(TBuffer&, char**
> const&, int, int, int, int) () from
> /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #16 0xb62ae1a9 in TStreamerInfoActions::GenericAction(TBuffer&, void*,
> TStreamerInfoActions::TConfiguration const*) ()
> from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #17 0xb626439c in
> TBufferFile::ReadSequence(TStreamerInfoActions::TActionSequence const&,
> void*) () from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #18 0xb626486b in TBufferFile::ReadClassBuffer(TClass const*, void*,
> TClass const*) () from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #19 0xb44d674e in Selector::Streamer(TBuffer&) ()
> from /tmp/tnagel/aclic_builddir/Selector_cc.so
> #20 0xb62a1afb in TKey::ReadObj() ()
> from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #21 0xb62751f1 in TDirectoryFile::Get(char const*) ()
> from /usr/local/root/root_v5.30.03/lib/libRIO.so.5.30
> #22 0xb727159e in ?? () from
> /usr/local/root/root_v5.30.03/lib/libCore.so.5.30
> ===========================================================
>
>
> Root > Function testpol() busy flag cleared
>
>
Received on Fri Dec 09 2011 - 14:58:41 CET

This archive was generated by hypermail 2.2.0 : Wed Dec 14 2011 - 11:50:01 CET