TSelector->Process call by object implemented?

Hello experts,
I develop a TSelector, and compile it with dictionary generation vi cint. All goes well, and I can make the selector, and if I call the selector by name like
inTree->Process(“MySel”,etc)
then the program works perfectly.

But I cannot call it by object–the program gives a bus error. I want to know if this feature is implemented–it would be very useful.

To isolate the problem, I have an empty selector–basically all the functions in the selector have no content.
The .h file is

#ifndef MySel_h
#define MySel_h

#include "headers.h"

class MySel: public TSelector {
 private :
  TTree          *outTree;

 public :
  TTree          *fChain;  

  MySel(TTree * /*tree*/ =0)  : fChain(0){cout << "***class instance created*** " << endl; }
  virtual ~MySel()     {cout << "~~~class instance destroyed~~~ " << endl; }
  virtual Int_t        Version() const { return 2; }
  virtual void         Begin(TTree *tree);
  virtual void         SlaveBegin(TTree *tree);
  virtual void         Init(TTree *intree);
  virtual Bool_t       Notify();
  virtual Bool_t       Process(Long64_t entry);
  virtual Int_t        GetEntry(Long64_t entry, Int_t getall = 0)  { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }
  virtual void         SetOption(const char *option) { fOption = option; }
  virtual void         SetObject(TObject *obj) { fObject = obj; }
  virtual void         SetInputList(TList *input) { fInput = input; }
  virtual TList        *GetOutputList() const { return fOutput; }
  virtual void         SlaveTerminate();
  virtual void         Terminate();


  ClassDef(MySel,2)

};
#endif
#ifdef MySel_cxx
  void MySel::Init(TTree *intree)
  {
  }

  Bool_t MySel::Notify()
  {
  } 
 #endif 

The .C file as I said is empty.

#include "MySel.h"
ClassImp(MySel);

void MySel::Begin(TTree * /*tree*/) 
{
}

void MySel::SlaveBegin(TTree * /*tree*/)
{
}

Bool_t MySel::Process(Long64_t entry)
{
}

void MySel::SlaveTerminate()
{
}

void MySel::Terminate()
{
}

The error I get is:

-bash-4.1$ ./selector result90000.root 
/nv/blue/mgv4ce/testingpi2e
 +++ Starting PROOF-Lite with 8 workers +++
Opening connections to workers: OK (8 workers)                 
Setting up worker servers: OK (8 workers)                 
PROOF set to parallel mode (8 workers)
13:27:36 195955 Wrk-0.0 | Info in <TProofServLite::HandleCache>: loading macro MySel.so ...
13:27:36 195957 Wrk-0.1 | Info in <TProofServLite::HandleCache>: loading macro MySel.so ...
13:27:36 195967 Wrk-0.6 | Info in <TProofServLite::HandleCache>: loading macro MySel.so ...
13:27:36 195969 Wrk-0.7 | Info in <TProofServLite::HandleCache>: loading macro MySel.so ...
13:27:36 195965 Wrk-0.5 | Info in <TProofServLite::HandleCache>: loading macro MySel.so ...
13:27:36 195959 Wrk-0.2 | Info in <TProofServLite::HandleCache>: loading macro MySel.so ...
13:27:36 195961 Wrk-0.3 | Info in <TProofServLite::HandleCache>: loading macro MySel.so ...
13:27:36 195963 Wrk-0.4 | Info in <TProofServLite::HandleCache>: loading macro MySel.so ...
***class instance created*** 
 
Info in <TProofLite::SetQueryRunning>: starting query: 1
Info in <TProofQueryResult::SetRunning>: nwrks: 8

trying to set the fChain
Looking up for exact location of files: OK (1 files)                 
Looking up for exact location of files: OK (1 files)                 
Info in <TPacketizer::TPacketizer>: Initial number of workers: 8
Validating files: OK (1 files)                 

 *** Break *** bus error



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00002b602ae1465e in waitpid () from /lib64/libc.so.6
#1  0x00002b602ada6609 in do_system () from /lib64/libc.so.6
#2  0x00002b60252d2338 in TUnixSystem::StackTrace (this=0x8da4d0) at /scratch/bkw1a/root_v5.34.28/core/unix/src/TUnixSystem.cxx:2419
#3  0x00002b60252d11b3 in TUnixSystem::DispatchSignals (this=0x8da4d0, sig=kSigBus) at /scratch/bkw1a/root_v5.34.28/core/unix/src/TUnixSystem.cxx:1294
#4  <signal handler called>
#5  0x00002b6024ee7f3c in operator<< <TBranch> (this=<value optimized out>, R(bool)=<value optimized out>) at /nv/blue/bkw1a/apps/root-5.34.28/include/TBuffer.h:387
#6  MySel::Streamer (this=<value optimized out>, R(bool)=<value optimized out>) at MySelDict.cxx:152
#7  0x00002b602660f98e in Streamer (this=0x7ffee49512b0, actualObjectStart=0x1113fd0, actualClass=0x116a760) at /scratch/bkw1a/root_v5.34.28/build/include/TClass.h:451
#8  TBufferFile::WriteObjectClass (this=0x7ffee49512b0, actualObjectStart=0x1113fd0, actualClass=0x116a760) at /scratch/bkw1a/root_v5.34.28/io/io/src/TBufferFile.cxx:2605
#9  0x00002b602660c564 in TBufferFile::WriteObjectAny (this=0x7ffee49512b0, obj=<value optimized out>, ptrClass=0xc0b990) at /scratch/bkw1a/root_v5.34.28/io/io/src/TBufferFile.cxx:2659
#10 0x00002b6025276990 in operator<< (this=<value optimized out>, b=...) at /scratch/bkw1a/root_v5.34.28/build/include/TBuffer.h:401
#11 TList::Streamer (this=<value optimized out>, b=...) at /scratch/bkw1a/root_v5.34.28/core/cont/src/TList.cxx:1070
#12 0x00002b602660f98e in Streamer (this=0x7ffee49512b0, actualObjectStart=0xcb2f80, actualClass=0x1114390) at /scratch/bkw1a/root_v5.34.28/build/include/TClass.h:451
#13 TBufferFile::WriteObjectClass (this=0x7ffee49512b0, actualObjectStart=0xcb2f80, actualClass=0x1114390) at /scratch/bkw1a/root_v5.34.28/io/io/src/TBufferFile.cxx:2605
#14 0x00002b602660c51f in TBufferFile::WriteObjectAny (this=0x7ffee49512b0, obj=0xcb2f80, ptrClass=0x1114390) at /scratch/bkw1a/root_v5.34.28/io/io/src/TBufferFile.cxx:2662
#15 0x00002b60299d5789 in operator<< <TList> (buf=..., obj=0xcb2f80) at /scratch/bkw1a/root_v5.34.28/build/include/TBuffer.h:388
#16 0x00002b6029d2130c in TProofPlayerLite::Process (this=0xcb2de0, dset=<value optimized out>, selector_file=<value optimized out>, option=0x0, nentries=0, first=0) at /scratch/bkw1a/root_v5.34.28/proof/proofplayer/src/TProofPlayerLite.cxx:266
#17 0x00002b6029d20278 in TProofPlayerLite::Process (this=0xcb2de0, dset=0x10c4b50, selector=<value optimized out>, option=0x7ffee49516d9 "", nentries=100000, first=0) at /scratch/bkw1a/root_v5.34.28/proof/proofplayer/src/TProofPlayerLite.cxx:97
#18 0x00002b6029995946 in TProofLite::Process (this=0xc053f0, dset=0x10c4b50, selector=0x0, option=<value optimized out>, nentries=100000, first=0) at /scratch/bkw1a/root_v5.34.28/proof/proof/src/TProofLite.cxx:1313
#19 0x00002b60299daec4 in TProof::Process (this=0xc053f0, dset=<value optimized out>, selector=<value optimized out>, option=<value optimized out>, nentries=<value optimized out>, first=<value optimized out>) at /scratch/bkw1a/root_v5.34.28/proof/proof/src/TProof.cxx:5687
#20 0x0000000000402976 in main (argc=<value optimized out>, argv=<value optimized out>) at main.cpp:79
===========================================================


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.
===========================================================
#5  0x00002b6024ee7f3c in operator<< <TBranch> (this=<value optimized out>, R(bool)=<value optimized out>) at /nv/blue/bkw1a/apps/root-5.34.28/include/TBuffer.h:387
#6  MySel::Streamer (this=<value optimized out>, R(bool)=<value optimized out>) at MySelDict.cxx:152
#7  0x00002b602660f98e in Streamer (this=0x7ffee49512b0, actualObjectStart=0x1113fd0, actualClass=0x116a760) at /scratch/bkw1a/root_v5.34.28/build/include/TClass.h:451
#8  TBufferFile::WriteObjectClass (this=0x7ffee49512b0, actualObjectStart=0x1113fd0, actualClass=0x116a760) at /scratch/bkw1a/root_v5.34.28/io/io/src/TBufferFile.cxx:2605
#9  0x00002b602660c564 in TBufferFile::WriteObjectAny (this=0x7ffee49512b0, obj=<value optimized out>, ptrClass=0xc0b990) at /scratch/bkw1a/root_v5.34.28/io/io/src/TBufferFile.cxx:2659
#10 0x00002b6025276990 in operator<< (this=<value optimized out>, b=...) at /scratch/bkw1a/root_v5.34.28/build/include/TBuffer.h:401
#11 TList::Streamer (this=<value optimized out>, b=...) at /scratch/bkw1a/root_v5.34.28/core/cont/src/TList.cxx:1070
#12 0x00002b602660f98e in Streamer (this=0x7ffee49512b0, actualObjectStart=0xcb2f80, actualClass=0x1114390) at /scratch/bkw1a/root_v5.34.28/build/include/TClass.h:451
#13 TBufferFile::WriteObjectClass (this=0x7ffee49512b0, actualObjectStart=0xcb2f80, actualClass=0x1114390) at /scratch/bkw1a/root_v5.34.28/io/io/src/TBufferFile.cxx:2605
#14 0x00002b602660c51f in TBufferFile::WriteObjectAny (this=0x7ffee49512b0, obj=0xcb2f80, ptrClass=0x1114390) at /scratch/bkw1a/root_v5.34.28/io/io/src/TBufferFile.cxx:2662
#15 0x00002b60299d5789 in operator<< <TList> (buf=..., obj=0xcb2f80) at /scratch/bkw1a/root_v5.34.28/build/include/TBuffer.h:388
#16 0x00002b6029d2130c in TProofPlayerLite::Process (this=0xcb2de0, dset=<value optimized out>, selector_file=<value optimized out>, option=0x0, nentries=0, first=0) at /scratch/bkw1a/root_v5.34.28/proof/proofplayer/src/TProofPlayerLite.cxx:266
#17 0x00002b6029d20278 in TProofPlayerLite::Process (this=0xcb2de0, dset=0x10c4b50, selector=<value optimized out>, option=0x7ffee49516d9 "", nentries=100000, first=0) at /scratch/bkw1a/root_v5.34.28/proof/proofplayer/src/TProofPlayerLite.cxx:97
#18 0x00002b6029995946 in TProofLite::Process (this=0xc053f0, dset=0x10c4b50, selector=0x0, option=<value optimized out>, nentries=100000, first=0) at /scratch/bkw1a/root_v5.34.28/proof/proof/src/TProofLite.cxx:1313
#19 0x00002b60299daec4 in TProof::Process (this=0xc053f0, dset=<value optimized out>, selector=<value optimized out>, option=<value optimized out>, nentries=<value optimized out>, first=<value optimized out>) at /scratch/bkw1a/root_v5.34.28/proof/proof/src/TProof.cxx:5687
#20 0x0000000000402976 in main (argc=<value optimized out>, argv=<value optimized out>) at main.cpp:79
===========================================================

If you want my main function here it is:

int main (int argc, char *argv[]) 
{
   const TString inFileName  = argv[1];

   TFile  *inFile = TFile::Open(inFileName);
   TChain *inTree = (TChain*)inFile->Get("usertree");
   TString workingDirectory = TString::Format("%s/", gSystem->WorkingDirectory());
   TString selectorLibrary = workingDirectory + "MySel.so";

   TProof *proof  = TProof::Open("workers=2");//"workers=8");
   proof->Load(selectorLibrary,kTRUE);
   inTree->SetProof(proof);
   Long64_t nentries=100000; Option_t *option="";
   MySel *s = new MySel();
   inTree->Process("MySel",option,nentries,0);//This works just fine
   //inTree->Process(s,option,nentries,0);//This breaks
   delete s;
   delete inTree;
   inFile->Close();
   return 0;
}

Dear mgv4ce,

Yes, it is implemented.
The problem seems to be with the streaming of the selector object.
How do you create the library MySel.so ?

G Ganis

Thanks for reply!

I use dictionary generation in my makefile. I attach my makefile and LinkDef.h

The output at compile time is:

-bash-4.1$ make
g++ -g -pthread -m64 -I/nv/blue/bkw1a/apps/root-5.34.28/include -fPIC -O2 -Wall -Wno-write-strings   -c -o MySel.o MySel.C
In file included from MySel.C:2:
MySel.h: In member function ‘virtual Bool_t MySel::Notify()’:
MySel.h:68: warning: no return statement in function returning non-void
MySel.C: In member function ‘virtual Bool_t MySel::Process(Long64_t)’:
MySel.C:55: warning: no return statement in function returning non-void
Compiling MySelDict.o
g++ -g -pthread -m64 -I/nv/blue/bkw1a/apps/root-5.34.28/include -fPIC -O2 -Wall -Wno-write-strings -L/nv/blue/bkw1a/apps/root-5.34.28/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lFoam -lProof -lProofPlayer -pthread -m64 -I/nv/blue/bkw1a/apps/root-5.34.28/include -m64 -I/nv/blue/bkw1a/apps/root-5.34.28/include -c MySelDict.cxx
-----------------------------------------------------
compiling MySel.so
g++ -g -pthread -m64 -I/nv/blue/bkw1a/apps/root-5.34.28/include -fPIC -O2 -Wall -Wno-write-strings -shared -o  MySel.so MySel.o MySelDict.o  -L/nv/blue/bkw1a/apps/root-5.34.28/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lFoam -lProof -lProofPlayer -lm -lz -lutil -lnsl -lpthread -L. -L/nv/blue/mgv4ce/testingpi2e 
MySel.so done
----------------------------------
Compiling selector
g++ -g -pthread -m64 -I/nv/blue/bkw1a/apps/root-5.34.28/include -fPIC -O2 -Wall -Wno-write-strings -o selector main.cpp /nv/blue/mgv4ce/testingpi2e/MySel.so -L/nv/blue/bkw1a/apps/root-5.34.28/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lFoam -lProof -lProofPlayer -lm -lz -lutil -lnsl -lpthread -L. -L/nv/blue/mgv4ce/testingpi2e 
--

LinkDef.h (148 Bytes)
makefile.txt (1.72 KB)

Dear mgv4ce,

The problem is probably somewhere here:

$(MYSELSO):     $(MYSELO)
	@echo "compiling $@"
	$(CXX) $(CXXFLAGS) $(SOFLAGS) $(OutPutOpt) $@ $^ $(EXPLLINKLIBS) $(LIBS)
	@echo "$@ done"

You should use $(LDFLAGS), properly defined. Have a look at, for example, proof/proof/Module.mk and related config files under config, e.g. Makefile.linux .

Otherwise you can use the ROOT shell to build your libs, it has all the settings right:

root[] .L MySel.C+

G Ganis