Dear Rooters,
I have be updating “old” analysis codes (worked with ROOT 5.*) to be compatibles with ROOT 6. I especially updated from the SetBranchAddress
approach to TTreeReader
for TTree.
It essentially works, in particular with TChain.
Some of my codes however used the TServerSocket
approached, similar to what is described in the (old, oudated ?) tutorials/legacy/net/treeClient.C
example.
This approach does work at the beginning of the process : data get sent, received by my other code, and the analysis (here via TSelector
) runs. Until another buffer is sent, which as the consequence to create a new TTree
(at least I see that the pointer as changed and the entry number is changed) and then the variables pointed by the TTreeReader
can not be found anymore.
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x000076b09d4ea3ea in __GI___wait4 (pid=3424914, stat_loc=stat_loc
entry=0x7ffe1f0e3d98, options=options
entry=0, usage=usage
entry=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
#1 0x000076b09d4ea3ab in __GI___waitpid (pid=<optimized out>, stat_loc=stat_loc
entry=0x7ffe1f0e3d98, options=options
entry=0) at ./posix/waitpid.c:38
#2 0x000076b09d450bdb in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:171
#3 0x000076b09e515a96 in TUnixSystem::StackTrace() () from /opt/cern/root/root_v6.32.10/lib/libCore.so
#4 0x000076b09e512d75 in TUnixSystem::DispatchSignals(ESignals) () from /opt/cern/root/root_v6.32.10/lib/libCore.so
#5 <signal handler called>
#6 0x000076b07df56c25 in ROOT::Internal::TTreeReaderValueBase::GetAddress() () from /opt/cern/root/root_v6.32.10/lib/libTreePlayer.so
#7 0x000076b08abdb5ef in ttree_analysis::ReadInitData(long long, long long) () from /data/RIKEN/DayOne/users/gib/macros/ttree_analysis_C.so
#8 0x000076b08abde0e1 in ttree_analysis::ProcessAnalysis(long long, bool) () from /data/RIKEN/DayOne/users/gib/macros/ttree_analysis_C.so
#9 0x000056be136e2042 in main (argc=6, argv=0x7ffe1f0e77f8) at start_process.C:200
===========================================================
The lines below might hint at the cause of the crash. If you see question
marks as part of the stack trace, try to recompile with debugging information
enabled and export CLING_DEBUG=1 environment variable before running.
You may get help by asking at the ROOT forum https://root.cern/forum
preferably using the command (.forum bug) in the ROOT prompt.
Only if you are really convinced it is a bug in ROOT then please submit a
report at https://root.cern/bugs or (preferably) using the command (.gh bug) in
the ROOT prompt. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#6 0x000076b07df56c25 in ROOT::Internal::TTreeReaderValueBase::GetAddress() () from /opt/cern/root/root_v6.32.10/lib/libTreePlayer.so
#7 0x000076b08abdb5ef in ttree_analysis::ReadInitData(long long, long long) () from /data/RIKEN/DayOne/users/gib/macros/ttree_analysis_C.so
#8 0x000076b08abde0e1 in ttree_analysis::ProcessAnalysis(long long, bool) () from /data/RIKEN/DayOne/users/gib/macros/ttree_analysis_C.so
#9 0x000056be136e2042 in main (argc=6, argv=0x7ffe1f0e77f8) at start_process.C:200
===========================================================
My question is then:
- is the TSocket approach outdated and there is something to replace ?
- how can I “reinitialize” the TTreeReader(s) ?
I add, not exactly the MWE example at the end, but more the main part of the codes.
Thank you very much in advance,
Best regards,
SENDER SIDE:
TMessage::EnableSchemaEvolutionForAll(kFALSE);
TMessage mess(kMESS_OBJECT);
.
.
.
loopoverevents {
.
.
.
every 1000 events {
.
.
.
mess.Reset(kMESS_OBJECT);
mess.WriteObject(tree);
sock->Send(mess);
.
.
.
}
}
RECEIVING END:
while(1){
TMessage *mess = new TMessage(kMESS_OBJECT);
if(sock->Recv(mess)){
if(!mess) break;
if(!mess->GetClass()) break;
if (mess->GetClass()->InheritsFrom(TTree::Class())) {
if(fin) {
fin->Clear();
fin->Close();
fin->Delete("slow");
}
if(tree) {
tree->Reset();
tree->Delete("slow");
}
fin = new TMemFile(filename,"new");
fin->cd();
tree = (TTree*) mess->ReadObject(mess->GetClass());
tree->SetDirectory(fin);
tree = (TTree*)fin->Get(argv[optind]);
if(!tree) {
abort();
}
tree->SetNotify(selector);
if(kToInit) {
selector->Begin(tree);
kToInit = kFALSE;
}
selector->Init(tree);
selector->Notify();
for (int entry=0;entry<tree->GetEntries();entry++) {
tree->LoadTree(entry);
selector->Process(entry);
}
std::cout << std::endl;
}
mess->Delete("slow");
}
}
ROOT Version: 6.32.10
Platform: Linux ubuntu22
Compiler: cpp (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0