Problem using TDCacheFile::SetOpenTimeout(..) in ACLiC lib

Hi all,

I’d like to set TDCacheFile::SetOpenTimeout() before opening a file in DCache. I’m having trouble doing this in a library compiled with aclic. Could someone offer advice?

If I compile the following file example_dcap_problem.C using aclic and run example_dcap_problem() in the same ROOT session, it succeeds. But, if I start a new ROOT session and load the library using “.L example_dcap_problem_C.so”, running example_dcap_problem() causes a segfault. The stack trace is posted below. Can someone offer advice how to use the library example_dcap_problem_C.so in a ROOT session separate from the one in which it was compiled?

(In fact, I see the same behavior even when I remove the line TDCacheFile::SetOpenTimeout(10). The segfault occurs whenever I #include “TDCacheFile.h”.)

I’m using 64bit SL5.1, with

uname -a
Linux hissh0002.cmsaf.mit.edu 2.6.18-194.11.1.el5 #1 SMP Tue Aug 10 16:39:28 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

root-5.26.00b, and dcap-2.47.2-0.x86_64.rpm.

thanks in advance,
Steve

example_dcap_problem.C:

#include "TChain.h"
#include "TDCacheFile.h"

void example_dcap_problem()
{
  // can comment this line out, and the behavior is the same:
  TDCacheFile::SetOpenTimeout(10);
  char* fname="dcache:/pnfs/cmsaf.mit.edu/t2bat/miniclean/jaditz/5_to_50keV_e/117897_0_1281818046_e.root";
  TChain* T=new TChain("T");
  T->AddFile(fname);
  T->Print();
  T->Delete();
}

When I compile:

root [1] .L example_dcap_problem.C++
Info in <TUnixSystem::ACLiC>: creating shared library /net/hisrv0001/home/jaditz/miniclean/anal/util/./example_dcap_problem_C.so
root [2] example_dcap_problem()
[... success ...]

Then in a new ROOT session:

root [0] .L example_dcap_problem_C.so
root [1] example_dcap_problem()

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x0000003109299325 in waitpid () from /lib64/libc.so.6
#1  0x000000310923c2e1 in do_system () from /lib64/libc.so.6
#2  0x00002ae4cb5adcc9 in TUnixSystem::StackTrace ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#3  0x00002ae4cb5ab8e3 in TUnixSystem::DispatchSignals ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#4  <signal handler called>
#5  0x0000003108e12811 in _dl_close () from /lib64/ld-linux-x86-64.so.2
#6  0x0000003108e0ceb6 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#7  0x0000003109a0150d in _dlerror_run () from /lib64/libdl.so.2
#8  0x0000003109a0104f in dlclose () from /lib64/libdl.so.2
#9  0x00002ae4d1a1d1e2 in initIfNeeded () at system_io.c:337
#10 0x00002ae4d1a1d2da in system_access (
    path=0xffffffffffffffff <Address 0xffffffffffffffff out of bounds>, mode=0) at system_io.c:707
#11 0x00002ae4d1a1c3ab in isPnfs (
    path=0x19b51500 "/pnfs/cmsaf.mit.edu/t2bat/miniclean/jaditz/5_to_50keV_e/117897_0_1281818046_e.root") at pnfs.c:82
#12 0x00002ae4d1a16bb1 in dc_open (
    fname=0x19b50738 "/pnfs/cmsaf.mit.edu/t2bat/miniclean/jaditz/5_to_50keV_e/117897_0_1281818046_e.root", flags=0) at dcap_open.c:102
#13 0x00002ae4d17fcd2a in TDCacheFile::SysOpen ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libDCache.so
#14 0x00002ae4d17fe092 in TDCacheFile::TDCacheFile ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libDCache.so
#15 0x00002ae4d18024cf in G__G__DCache_190_0_9 ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libDCache.so
#16 0x00002ae4cbde1750 in Cint::G__CallFunc::Execute ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#17 0x00002ae4cb593b71 in TCint::CallFunc_ExecInt ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#18 0x00002ae4cb584ead in TMethodCall::Execute ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#19 0x00002ae4cb501bfc in TPluginHandler::ExecPlugin ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#20 0x00002ae4cc75fb5f in TFile::Open ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libRIO.so
#21 0x00002ae4cdf270e2 in TChain::Print ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libTree.so
#22 0x00002ae4d11eeec7 in example_dcap_problem ()
   from /net/hisrv0001/home/jaditz/miniclean/anal/util/./example_dcap_problem_C.so
#23 0x00002ae4d11eef09 in G__example_dcap_problem_C_ACLiC_dict__0_1576 ()
   from /net/hisrv0001/home/jaditz/miniclean/anal/util/./example_dcap_problem_C.so
#24 0x00002ae4cbdb1f5a in Cint::G__ExceptionWrapper ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#25 0x00002ae4cbe5e460 in G__execute_call ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#26 0x00002ae4cbe606e9 in G__call_cppfunc ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#27 0x00002ae4cbe3a5fe in G__interpret_func ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#28 0x00002ae4cbe27e54 in G__getfunction ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#29 0x00002ae4cbdfd2d4 in G__getitem ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#30 0x00002ae4cbe083c2 in G__getexpr ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#31 0x00002ae4cbe8d83f in G__exec_statement ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#32 0x00002ae4cbde9596 in G__exec_tempfile_core ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#33 0x00002ae4cbde98ae in G__exec_tempfile_fp ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#34 0x00002ae4cbe989df in G__process_cmd ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#35 0x00002ae4cb5972b7 in TCint::ProcessLine ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#36 0x00002ae4cb4d4213 in TApplication::ProcessLine ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#37 0x00002ae4ce2a0213 in TRint::HandleTermInput ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libRint.so
#38 0x00002ae4ce29ec57 in TTermInputHandler::Notify ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libRint.so
#39 0x00002ae4ce2a128d in TTermInputHandler::ReadNotify ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libRint.so
#40 0x00002ae4cb5aac63 in TUnixSystem::CheckDescriptors ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#41 0x00002ae4cb5ab30c in TUnixSystem::DispatchOneEvent ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#42 0x00002ae4cb52a236 in TSystem::InnerLoop ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#43 0x00002ae4cb52d0a1 in TSystem::Run ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#44 0x00002ae4cb4d26ff in TApplication::Run ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#45 0x00002ae4ce2a0e80 in TRint::Run ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libRint.so
#46 0x000000000040163a 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.
===========================================================
#5  0x0000003108e12811 in _dl_close () from /lib64/ld-linux-x86-64.so.2
#6  0x0000003108e0ceb6 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#7  0x0000003109a0150d in _dlerror_run () from /lib64/libdl.so.2
#8  0x0000003109a0104f in dlclose () from /lib64/libdl.so.2
#9  0x00002ae4d1a1d1e2 in initIfNeeded () at system_io.c:337
#10 0x00002ae4d1a1d2da in system_access (
    path=0xffffffffffffffff <Address 0xffffffffffffffff out of bounds>, mode=0) at system_io.c:707
#11 0x00002ae4d1a1c3ab in isPnfs (
    path=0x19b51500 "/pnfs/cmsaf.mit.edu/t2bat/miniclean/jaditz/5_to_50keV_e/117897_0_1281818046_e.root") at pnfs.c:82
#12 0x00002ae4d1a16bb1 in dc_open (
    fname=0x19b50738 "/pnfs/cmsaf.mit.edu/t2bat/miniclean/jaditz/5_to_50keV_e/117897_0_1281818046_e.root", flags=0) at dcap_open.c:102
#13 0x00002ae4d17fcd2a in TDCacheFile::SysOpen ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libDCache.so
#14 0x00002ae4d17fe092 in TDCacheFile::TDCacheFile ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libDCache.so
===========================================================

Hi,

can you try to use second time also:

.L example_dcap_problem.C+

notice on plus, so you don’t recompile if not needed.

Cheers, Fons.

Hi Fons,

thanks for the reply. A similar segfault also occurs when I load the library as you say.

thanks,
Steve

root [0] .L example_dcap_problem.C+
root [1] example_dcap_problem()

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00000036c4899325 in waitpid () from /lib64/libc.so.6
#1  0x00000036c483c2e1 in do_system () from /lib64/libc.so.6
#2  0x00002b3cc1bb1cc9 in TUnixSystem::StackTrace ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#3  0x00002b3cc1baf8e3 in TUnixSystem::DispatchSignals ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#4  <signal handler called>
#5  0x00000036c4412811 in _dl_close () from /lib64/ld-linux-x86-64.so.2
#6  0x00000036c440ceb6 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#7  0x00000036c500150d in _dlerror_run () from /lib64/libdl.so.2
#8  0x00000036c500104f in dlclose () from /lib64/libdl.so.2
#9  0x00002b3cc8e3a1e2 in initIfNeeded () at system_io.c:337
#10 0x00002b3cc8e3a2da in system_access (
    path=0xffffffffffffffff <Address 0xffffffffffffffff out of bounds>, mode=0) at system_io.c:707
#11 0x00002b3cc8e393ab in isPnfs (
    path=0x1c675e50 "/pnfs/cmsaf.mit.edu/t2bat/miniclean/jaditz/5_to_50keV_e/117897_0_1281818046_e.root") at pnfs.c:82
#12 0x00002b3cc8e33bb1 in dc_open (
    fname=0x1c675088 "/pnfs/cmsaf.mit.edu/t2bat/miniclean/jaditz/5_to_50keV_e/117897_0_1281818046_e.root", flags=0) at dcap_open.c:102
#13 0x00002b3cc8c19d2a in TDCacheFile::SysOpen ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libDCache.so
#14 0x00002b3cc8c1b092 in TDCacheFile::TDCacheFile ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libDCache.so
#15 0x00002b3cc8c1f4cf in G__G__DCache_190_0_9 ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libDCache.so
#16 0x00002b3cc23e5750 in Cint::G__CallFunc::Execute ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#17 0x00002b3cc1b97b71 in TCint::CallFunc_ExecInt ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#18 0x00002b3cc1b88ead in TMethodCall::Execute ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#19 0x00002b3cc1b05bfc in TPluginHandler::ExecPlugin ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#20 0x00002b3cc2d63b5f in TFile::Open ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libRIO.so
#21 0x00002b3cc452b0e2 in TChain::Print ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libTree.so
#22 0x00002b3cc860be7d in example_dcap_problem ()
   from /net/hisrv0001/home/jaditz/miniclean/anal/util/./example_dcap_problem_C.so
#23 0x00002b3cc860beb9 in G__example_dcap_problem_C_ACLiC_dict__0_1576 ()
   from /net/hisrv0001/home/jaditz/miniclean/anal/util/./example_dcap_problem_C.so
#24 0x00002b3cc23b5f5a in Cint::G__ExceptionWrapper ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#25 0x00002b3cc2462460 in G__execute_call ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#26 0x00002b3cc24646e9 in G__call_cppfunc ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#27 0x00002b3cc243e5fe in G__interpret_func ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#28 0x00002b3cc242be54 in G__getfunction ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#29 0x00002b3cc24012d4 in G__getitem ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#30 0x00002b3cc240c3c2 in G__getexpr ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#31 0x00002b3cc249183f in G__exec_statement ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#32 0x00002b3cc23ed596 in G__exec_tempfile_core ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#33 0x00002b3cc23ed8ae in G__exec_tempfile_fp ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#34 0x00002b3cc249c9df in G__process_cmd ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCint.so
#35 0x00002b3cc1b9b2b7 in TCint::ProcessLine ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#36 0x00002b3cc1ad8213 in TApplication::ProcessLine ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#37 0x00002b3cc48a4213 in TRint::HandleTermInput ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libRint.so
#38 0x00002b3cc48a2c57 in TTermInputHandler::Notify ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libRint.so
#39 0x00002b3cc48a528d in TTermInputHandler::ReadNotify ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libRint.so
#40 0x00002b3cc1baec63 in TUnixSystem::CheckDescriptors ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#41 0x00002b3cc1baf30c in TUnixSystem::DispatchOneEvent ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#42 0x00002b3cc1b2e236 in TSystem::InnerLoop ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#43 0x00002b3cc1b310a1 in TSystem::Run ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#44 0x00002b3cc1ad66ff in TApplication::Run ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libCore.so
#45 0x00002b3cc48a4e80 in TRint::Run ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libRint.so
#46 0x000000000040163a 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.
===========================================================
#5  0x00000036c4412811 in _dl_close () from /lib64/ld-linux-x86-64.so.2
#6  0x00000036c440ceb6 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#7  0x00000036c500150d in _dlerror_run () from /lib64/libdl.so.2
#8  0x00000036c500104f in dlclose () from /lib64/libdl.so.2
#9  0x00002b3cc8e3a1e2 in initIfNeeded () at system_io.c:337
#10 0x00002b3cc8e3a2da in system_access (
    path=0xffffffffffffffff <Address 0xffffffffffffffff out of bounds>, mode=0) at system_io.c:707
#11 0x00002b3cc8e393ab in isPnfs (
    path=0x1c675e50 "/pnfs/cmsaf.mit.edu/t2bat/miniclean/jaditz/5_to_50keV_e/117897_0_1281818046_e.root") at pnfs.c:82
#12 0x00002b3cc8e33bb1 in dc_open (
    fname=0x1c675088 "/pnfs/cmsaf.mit.edu/t2bat/miniclean/jaditz/5_to_50keV_e/117897_0_1281818046_e.root", flags=0) at dcap_open.c:102
#13 0x00002b3cc8c19d2a in TDCacheFile::SysOpen ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libDCache.so
#14 0x00002b3cc8c1b092 in TDCacheFile::TDCacheFile ()
   from /net/t2srv0008/d00/miniclean/ratcage.20100608/root-5.26.00b/lib/libDCache.so
===========================================================

And doing for a second time

.L example_dcap_problem.C++

i.e. should do the same as the first time. It looks like there is something not correctly initialized in the dcap lib when running again. We’ll investigate.

Cheers, Fons.

the problem is that we use LD_NEXT in dlopen call. If it happens
that libc loaded prior libdcap, then we miss system calls with
nasty errors. May be you can fix that by explicitly linking libc with
example_dcap_problem_C.so

Regards,
Tigran.

Hi Tigran,

I think you meant to link libdcap, not libc. And indeed it works. Thanks!

Steve