Wrong class composing in TSelector

Hi everyone,

We are working on some tools that run over PROOF. One of our ideas is the possibility of creating a chain of analysers. To reach this chain, we are using a composite pattern but this is out of our trouble. The trouble, I guess, is the use of a wrong class composing in TSelector.

Let me explain, we will suppose we have a class called Selector which don’t extends any other class. Selector class has 3 methods, Initialise, Loop and Summary which will be called respectively in TSelector::SlaveBegin, TSelector::Process and TSelector::Terminate. This design forces us to create a TSelector composed by a Selector. And here is the trouble, Selector only execute methods on client, workers don’t get access to Selector I guess. So, to fix it, What should we do? Should we implement TObject in Selector to solve it or anything more?

If someone needs more information, I have attached this example using hands-on tutorial code. At least, It shows an “Events skipped” message, but development version shows execution statistics as events executed.

To launch:
.L Selector.C+
.L ChainTSelector.C+
ChainTSelector* cts = new ChainTSelector();
Selector* s = new Selector();
cts->SetSelector(s);
TProof* proof = TProof::Open(“lite://”);
proof->Process(cts, 10000000);

Greetings and thanks,
Javier Delgado.
Selector.h (445 Bytes)
Selector.C (2.46 KB)
ChainTSelector.h (855 Bytes)
ChainTSelector.C (384 Bytes)

Hi everyone again,

In order to solve our trouble, I’ve extended Selector from TObject using ClassDef and ClassImp. It was easier as I thought. Also I’ve made the PAR files to load in Proof but we are still in trouble. It is now working using TProof::Process(const char* selector, Long64_t nentries), but recently, TProof has implemented a new method, TProof::Process(TSelector* selector, Long64_t nentries), which does not work for me, at least, as I understand. I guess the new method will serialize the object and send to the slaves (which also have the class), but it appears that can’t serialize Selector (now extends TObject). It also crash with an empty method implementation in ChainItemSelector (TSelector), just appearing Selector as a field of ChainTitemSelector.

Could anyone help me?

I’ve attached source files updated, PAR files and a “Launcher.c”.
To test it:
.x Launcher.c

And if you want to see how it works properly, open “Launcher.c” and comment and uncomment some lines.

Here is the stack trace:

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

#0 0x000000378b299dd5 in waitpid () from /lib64/libc.so.6
#1 0x000000378b23c4a1 in do_system () from /lib64/libc.so.6
#2 0x00002b9be24d00c2 in TUnixSystem::StackTrace() ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#3 0x00002b9be24cceea in TUnixSystem::DispatchSignals(ESignals) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#4
#5 0x00002b9be922f79b in TBuffer& operator<< (TBuffer&, Selector const*) ()
from /{dir}/user/javierdelgado/.proof/packages/ChainTSelector/./libChainTSelector.so
#6 0x00002b9be922f5eb in ChainTSelector::Streamer(TBuffer&) ()
from /{dir}/user/javierdelgado/.proof/packages/ChainTSelector/./libChainTSelector.so
#7 0x00002b9be49186a3 in TBufferFile::WriteObjectClass(void const*, TClass const*) () from /{dir}/root_releases/root.5.34.21.slc5/lib/libRIO.so
#8 0x00002b9be4913813 in TBufferFile::WriteObjectAny(void const*, TClass const*) () from /{dir}/root_releases/root.5.34.21.slc5/lib/libRIO.so
#9 0x00002b9be24769ea in TList::Streamer(TBuffer&) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#10 0x00002b9be49186a3 in TBufferFile::WriteObjectClass(void const*, TClass const*) () from /{dir}/root_releases/root.5.34.21.slc5/lib/libRIO.so
#11 0x00002b9be49137e8 in TBufferFile::WriteObjectAny(void const*, TClass const*) () from /{dir}/root_releases/root.5.34.21.slc5/lib/libRIO.so
#12 0x00002b9be25fe713 in TBuffer& operator<< (TBuffer&, TList const*)
() from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#13 0x00002b9be6a4f47e in TProofPlayerLite::Process(TDSet*, char const*, char const*, long long, long long) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libProofPlayer.so
#14 0x00002b9be6a4df5b in TProofPlayerLite::Process(TDSet*, TSelector*, char const*, long long, long long) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libProofPlayer.so
#15 0x00002b9be563113e in TProofLite::Process(TDSet*, char const*, char const*, long long, long long) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libProof.so
#16 0x00002b9be55f09f4 in TProof::Process(TDSet*, TSelector*, char const*, long long, long long) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libProof.so
#17 0x00002b9be55f6799 in TProof::Process(char const*, long long, char const*)
() from /{dir}/root_releases/root.5.34.21.slc5/lib/libProof.so
#18 0x00002b9be55f0b54 in TProof::Process(TSelector*, long long, char const*)
() from /{dir}/root_releases/root.5.34.21.slc5/lib/libProof.so
#19 0x00002b9be5699bd6 in G__G__Proof_238_0_145(G__value*, char const*, G__param*, int) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libProof.so
#20 0x00002b9be2ecc82d in Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__param*, int), G__value*, char*, G__param*, int) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#21 0x00002b9be2f7e010 in G__execute_call ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#22 0x00002b9be2f7fa8b in G__call_cppfunc ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#23 0x00002b9be2f58a2c in G__interpret_func ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#24 0x00002b9be2f47efe in G__getfunction ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#25 0x00002b9be3037d76 in G__getstructmem(int, G__FastAllocString&, char*, int, char*, int*, G__var_array*, int) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#26 0x00002b9be302db36 in G__getvariable ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#27 0x00002b9be2f1aacf in G__getitem ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#28 0x00002b9be2f25261 in G__getexpr ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#29 0x00002b9be2fb1d20 in G__exec_statement ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#30 0x00002b9be2f59e27 in G__interpret_func ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#31 0x00002b9be2f48068 in G__getfunction ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#32 0x00002b9be2f1ac3d in G__getitem ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#33 0x00002b9be2f25261 in G__getexpr ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#34 0x00002b9be2f2c69d in G__calc_internal ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#35 0x00002b9be2fbc031 in G__process_cmd ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCint.so
#36 0x00002b9be24878dd in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#37 0x00002b9be24873b3 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#38 0x00002b9be23ddf6e in TApplication::ExecuteFile(char const*, int*, bool) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#39 0x00002b9be23dd418 in TApplication::ProcessLine(char const*, bool, int*) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#40 0x00002b9be2c2d0c2 in TRint::HandleTermInput() ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libRint.so
#41 0x00002b9be2c2c457 in TTermInputHandler::Notify() ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libRint.so
#42 0x00002b9be2c2ed1d in TTermInputHandler::ReadNotify() ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libRint.so
#43 0x00002b9be24ccb23 in TUnixSystem::CheckDescriptors() ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#44 0x00002b9be24cd05e in TUnixSystem::DispatchOneEvent(bool) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#45 0x00002b9be243e566 in TSystem::InnerLoop() ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#46 0x00002b9be2441cf1 in TSystem::Run() ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#47 0x00002b9be23d94ef in TApplication::Run(bool) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#48 0x00002b9be2c2e9b5 in TRint::Run(bool) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libRint.so
#49 0x0000000000400fcd 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
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.

#5 0x00002b9be922f79b in TBuffer& operator<< (TBuffer&, Selector const*) ()
from /{dir}/user/javierdelgado/.proof/packages/ChainTSelector/./libChainTSelector.so
#6 0x00002b9be922f5eb in ChainTSelector::Streamer(TBuffer&) ()
from /{dir}/user/javierdelgado/.proof/packages/ChainTSelector/./libChainTSelector.so
#7 0x00002b9be49186a3 in TBufferFile::WriteObjectClass(void const*, TClass const*) () from /{dir}/root_releases/root.5.34.21.slc5/lib/libRIO.so
#8 0x00002b9be4913813 in TBufferFile::WriteObjectAny(void const*, TClass const*) () from /{dir}/root_releases/root.5.34.21.slc5/lib/libRIO.so
#9 0x00002b9be24769ea in TList::Streamer(TBuffer&) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#10 0x00002b9be49186a3 in TBufferFile::WriteObjectClass(void const*, TClass const*) () from /{dir}/root_releases/root.5.34.21.slc5/lib/libRIO.so
#11 0x00002b9be49137e8 in TBufferFile::WriteObjectAny(void const*, TClass const*) () from /{dir}/root_releases/root.5.34.21.slc5/lib/libRIO.so
#12 0x00002b9be25fe713 in TBuffer& operator<< (TBuffer&, TList const*)
() from /{dir}/root_releases/root.5.34.21.slc5/lib/libCore.so
#13 0x00002b9be6a4f47e in TProofPlayerLite::Process(TDSet*, char const*, char const*, long long, long long) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libProofPlayer.so
#14 0x00002b9be6a4df5b in TProofPlayerLite::Process(TDSet*, TSelector*, char const*, long long, long long) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libProofPlayer.so
#15 0x00002b9be563113e in TProofLite::Process(TDSet*, char const*, char const*, long long, long long) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libProof.so
#16 0x00002b9be55f09f4 in TProof::Process(TDSet*, TSelector*, char const*, long long, long long) ()
from /{dir}/root_releases/root.5.34.21.slc5/lib/libProof.so
#17 0x00002b9be55f6799 in TProof::Process(char const*, long long, char const*)
() from /{dir}/root_releases/root.5.34.21.slc5/lib/libProof.so
#18 0x00002b9be55f0b54 in TProof::Process(TSelector*, long long, char const*)
() from /{dir}/root_releases/root.5.34.21.slc5/lib/libProof.so

Root > Function Launcher() busy flag cleared

Greetings and thanks,
Javier Delgado.
Files.zip (12.2 KB)

Hi,

Sorry for the late reply.
The way you are structuring looks fine as far as I can tell.
There are two issues, as far as I can see.
One is with the PAR files which do not seem to build, at least on Mac, where I have tried. I did not debug this since is not the crucial point for now.
The second is with the streamer of ChainTSelector. This is is due to the fact that your fSelector member is not initialised in the constructor (the streaming process needs to create default instances, and if proper initialisation is missing you get garbage and crashes).
Fixing this it works for me. See attachment.
Also, you may consider to add ‘//!’ after the definition of members you do not need to stream.

As you can see in the modified version of Launcher.c, in these simple cases you can use TProof::Load to load the required classes. For more complicated classes it is better to use a PAR file.

Hope it helps,

G. Ganis
Files-1.zip (3 KB)

Thank you so much Ganis.

Yep, as you could imagine, this is my first contact with this kind of programming languages, and although I was aware of that problem (not initialization of fields in default value), I was blind. I’ve solved some more related issues and now all works properly.

And thanks for these tips, I also have in mind the use of PAR files. The issue in Mac is due to a script used to generate PAR files, which for now don’t support OS X.

Thanks you so much again Ganis,
Javier Delgado.