Function busy flag cleared

Hi ROOTers,

I’ve attached two files to this post. One is my C/C++ macro that I want to run with ROOT. It contains a function void MotherIDTester2(), which itself calls void OpenAndRead() for several .root data files. All non-standard functions are defined in CellList.h.

I have tried loading the macro, using .L MotherIDTester2.C in ROOT. I can then use any function within the macro, try them out with examples and so on, and everything works fine. However, when I try to run the full macro, by typing

root -l MotherIDTester2.C

I get the following message:

[quote]root [0]
Processing MotherIDTester2.C…
33528

*** Break *** segmentation violation

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

Thread 6 (Thread 0x7fb477eec700 (LWP 9060)):
#0 0x00007fb47d543fa3 in epoll_wait () from /lib64/libc.so.6
#1 0x00007fb4783cdbe2 in XrdSys::IOEvents::PollE::Begin(XrdSysSemaphore*, int&, char const**) () from /usr/lib64/libXrdUtils.so.2
#2 0x00007fb4783cc49d in XrdSys::IOEvents::BootStrap::Start(void*) () from /usr/lib64/libXrdUtils.so.2
#3 0x00007fb4783ca3af in XrdSysThread_Xeq () from /usr/lib64/libXrdUtils.so.2
#4 0x00007fb47bdd9a51 in start_thread () from /lib64/libpthread.so.0
#5 0x00007fb47d5439ad in clone () from /lib64/libc.so.6

Thread 5 (Thread 0x7fb4774eb700 (LWP 9061)):
#0 0x00007fb47d507aed in nanosleep () from /lib64/libc.so.6
#1 0x00007fb4783ca447 in XrdSysTimer::Wait(int) () from /usr/lib64/libXrdUtils.so.2
#2 0x00007fb47814239c in XrdCl::TaskManager::RunTasks() () from /usr/lib64/libXrdCl.so.2
#3 0x00007fb478142529 in ?? () from /usr/lib64/libXrdCl.so.2
#4 0x00007fb47bdd9a51 in start_thread () from /lib64/libpthread.so.0
#5 0x00007fb47d5439ad in clone () from /lib64/libc.so.6

Thread 4 (Thread 0x7fb476aea700 (LWP 9062)):
#0 0x00007fb47d540209 in syscall () from /lib64/libc.so.6
#1 0x00007fb4781362c9 in XrdSys::LinuxSemaphore::Wait() () from /usr/lib64/libXrdCl.so.2
#2 0x00007fb47817dc02 in XrdCl::JobManager::RunJobs() () from /usr/lib64/libXrdCl.so.2
#3 0x00007fb47817dc69 in ?? () from /usr/lib64/libXrdCl.so.2
#4 0x00007fb47bdd9a51 in start_thread () from /lib64/libpthread.so.0
#5 0x00007fb47d5439ad in clone () from /lib64/libc.so.6

Thread 3 (Thread 0x7fb4760e9700 (LWP 9063)):
#0 0x00007fb47d540209 in syscall () from /lib64/libc.so.6
#1 0x00007fb4781362c9 in XrdSys::LinuxSemaphore::Wait() () from /usr/lib64/libXrdCl.so.2
#2 0x00007fb47817dc02 in XrdCl::JobManager::RunJobs() () from /usr/lib64/libXrdCl.so.2
#3 0x00007fb47817dc69 in ?? () from /usr/lib64/libXrdCl.so.2
#4 0x00007fb47bdd9a51 in start_thread () from /lib64/libpthread.so.0
#5 0x00007fb47d5439ad in clone () from /lib64/libc.so.6

Thread 2 (Thread 0x7fb4756e8700 (LWP 9064)):
#0 0x00007fb47d540209 in syscall () from /lib64/libc.so.6
#1 0x00007fb4781362c9 in XrdSys::LinuxSemaphore::Wait() () from /usr/lib64/libXrdCl.so.2
#2 0x00007fb47817dc02 in XrdCl::JobManager::RunJobs() () from /usr/lib64/libXrdCl.so.2
#3 0x00007fb47817dc69 in ?? () from /usr/lib64/libXrdCl.so.2
#4 0x00007fb47bdd9a51 in start_thread () from /lib64/libpthread.so.0
#5 0x00007fb47d5439ad in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7fb47ecbd0e0 (LWP 9053)):
#0 0x00007fb47d50770d in waitpid () from /lib64/libc.so.6
#1 0x00007fb47d499609 in do_system () from /lib64/libc.so.6
#2 0x00007fb47d499940 in system () from /lib64/libc.so.6
#3 0x00007fb47e1aa8f4 in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.5.34
#4 0x00007fb47e1a9d13 in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib64/root/libCore.so.5.34
#5
#6 0x00007fb47ca0bb95 in G__LD_p0_int () from /usr/lib64/root/libCint.so.5.34
#7 0x00007fb47c941b03 in G__exec_asm () from /usr/lib64/root/libCint.so.5.34
#8 0x00007fb47c94ad29 in G__exec_bytecode () from /usr/lib64/root/libCint.so.5.34
#9 0x00007fb47c9ac49d in G__interpret_func () from /usr/lib64/root/libCint.so.5.34
#10 0x00007fb47c99b918 in G__getfunction () from /usr/lib64/root/libCint.so.5.34
#11 0x00007fb47c97a12e in G__getitem () from /usr/lib64/root/libCint.so.5.34
#12 0x00007fb47c97ecb8 in G__getexpr () from /usr/lib64/root/libCint.so.5.34
#13 0x00007fb47c96a10e in G__define_var () from /usr/lib64/root/libCint.so.5.34
#14 0x00007fb47c9fb27c in G__exec_statement () from /usr/lib64/root/libCint.so.5.34
#15 0x00007fb47ca0068b in ?? () from /usr/lib64/root/libCint.so.5.34
#16 0x00007fb47c9fc651 in G__exec_statement () from /usr/lib64/root/libCint.so.5.34
#17 0x00007fb47ca0068b in ?? () from /usr/lib64/root/libCint.so.5.34
#18 0x00007fb47c9fc651 in G__exec_statement () from /usr/lib64/root/libCint.so.5.34
#19 0x00007fb47c9addd9 in G__interpret_func () from /usr/lib64/root/libCint.so.5.34
#20 0x00007fb47c99b918 in G__getfunction () from /usr/lib64/root/libCint.so.5.34
#21 0x00007fb47c97a12e in G__getitem () from /usr/lib64/root/libCint.so.5.34
#22 0x00007fb47c97ecb8 in G__getexpr () from /usr/lib64/root/libCint.so.5.34
#23 0x00007fb47c9f9be7 in G__exec_statement () from /usr/lib64/root/libCint.so.5.34
#24 0x00007fb47c9addd9 in G__interpret_func () from /usr/lib64/root/libCint.so.5.34
#25 0x00007fb47c99b918 in G__getfunction () from /usr/lib64/root/libCint.so.5.34
#26 0x00007fb47c97a12e in G__getitem () from /usr/lib64/root/libCint.so.5.34
#27 0x00007fb47c97ecb8 in G__getexpr () from /usr/lib64/root/libCint.so.5.34
#28 0x00007fb47c9881c8 in G__calc_internal () from /usr/lib64/root/libCint.so.5.34
#29 0x00007fb47ca07275 in G__process_cmd () from /usr/lib64/root/libCint.so.5.34
#30 0x00007fb47e16aa36 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /usr/lib64/root/libCore.so.5.34
#31 0x00007fb47e1681a3 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /usr/lib64/root/libCore.so.5.34
#32 0x00007fb47e0cf036 in TApplication::ExecuteFile(char const*, int*, bool) () from /usr/lib64/root/libCore.so.5.34
#33 0x00007fb47e0ce4e3 in TApplication::ProcessLine(char const*, bool, int*) () from /usr/lib64/root/libCore.so.5.34
#34 0x00007fb47dd1e811 in TRint::Run(bool) () from /usr/lib64/root/libRint.so.5.34
#35 0x000000000040103c in main ()

The crash is most likely caused by a problem in your script.
Try to compile it (.L myscript.C+g) and fix any errors.
If that does not help 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.

Root > Function Get() busy flag cleared
Function OpenAndRead() busy flag cleared
Function MotherIDTester2() busy flag cleared
[/quote]

And when I do, as suggested above:

.L MotherIDTester2.C+g

I get:

[quote]root [1] .L MotherIDTester2.C+g
Info in : script has already been loaded in interpreted mode
Info in : unloading /afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C and compiling it
Info in TUnixSystem::ACLiC: creating shared library /afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2_C.so
In file included from /afs/cern.ch/user/r/ravina/TEST/MotherIDTester2_C_ACLiC_dict.h:34,
from /afs/cern.ch/user/r/ravina/TEST/MotherIDTester2_C_ACLiC_dict.cxx:17:
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C: In function ‘void OpenAndRead(char*)’:
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C:4: error: ‘TFile’ was not declared in this scope
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C:4: error: ‘file’ was not declared in this scope
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C:4: error: ‘TFile’ is not a class or namespace
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C:5: error: ‘TTree’ was not declared in this scope
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C:5: error: ‘tree’ was not declared in this scope
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C:5: error: expected primary-expression before ‘)’ token
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C:5: error: expected ‘;’ before ‘file’
In file included from /afs/cern.ch/user/r/ravina/TEST/MotherIDTester2_C_ACLiC_dict.h:34,
from /afs/cern.ch/user/r/ravina/TEST/MotherIDTester2_C_ACLiC_dict.cxx:17:
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C: In function ‘void MotherIDTester2()’:
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C:52: warning: deprecated conversion from string constant to ‘char*’
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C:53: warning: deprecated conversion from string constant to ‘char*’
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C:54: warning: deprecated conversion from string constant to ‘char*’
/afs/cern.ch/user/r/ravina/TEST/./MotherIDTester2.C:55: warning: deprecated conversion from string constant to ‘char*’
g++: /afs/cern.ch/user/r/ravina/TEST/MotherIDTester2_C_ACLiC_dict.o: No such file or directory
Error in : Compilation failed!
!!!Dictionary position not recovered because G__unloadfile() is used in a macro!!!
*** Interpreter error recovered ***
[/quote]

I have no idea what to do.
MotherIDTester2.C (1.61 KB)
CellList.h (1.19 KB)

Try to execute:
root-config --cxx --cflags -O2 -W -Wall -c MotherIDTester2.C
and fix all compiler errors / warnings.
Start with missing (in the “MotherIDTester2.C”):
#include “TFile.h”
#include “TTree.h”
#include
and modify the definition:
void OpenAndRead(const char *address) {

I fixed the errors by including “TFile.h”, “TTree.h”, and changing char* to char const* in the declaration of OpenAndRead.

What now?

They try:
root[0] .x MotherIDTester2.C++

P.S. Maybe two modifications could be done:

TFile *file = TFile::Open(address); if (!file) return; TTree *tree = (TTree*)file->Get("DsggTree/DecayTree"); if (!tree) { delete file; return; } and then replace:
file->Close();
with:
delete file; // automatically deletes “tree”, too

It works! Thank you :slight_smile: