TDCacheFile Problem

Hi,
i`m trying to access a file on DCahce from a compiled root cc; if i do this from command line i have no problems:

root [0] TFile oldfile = new TDCacheFile(“dcap://cmsrm-se01.roma1.infn.it/pnfs/roma1.infn.it/data/cms/store/user/cartag/prova.root”,“READ”)
root [1] oldfile->ls() TDCacheFile
* dcap://cmsrm-se01.roma1.infn.it/pnfs/ro … prova.root
TDCacheFile* dcap://cmsrm-se01.roma1.infn.it/pnfs/ro … prova.root
KEY: TTree ntp1;7 ntp1
KEY: TTree ntp1;6 ntp1

if i try to do this compiling a .cc

// C++
#include
#include
#include
#include
#include
#include <stdio.h>

// Root
#include “TDCacheFile.h”
#include “TFile.h”
#include “TTree.h”
#include “TChain.h”
#include “TBranch.h”
#include “TString.h”

int main () {

TFile *oldfile = new TDCacheFile(“dcap://cmsrm-se01.roma1.infn.it/pnfs/roma1.infn.it/data/cms/store/user/cartag/prova.root”,“READ”);

std::cout << "file read" << std::endl;
std::fflush(stdout);


}

I have a segmentation violation:

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

#0 0x00000037d3c9a115 in waitpid () from /lib64/libc.so.6
#1 0x00000037d3c3c481 in do_system () from /lib64/libc.so.6
#2 0x00002adf3ea64222 in TUnixSystem::StackTrace() ()
from /opt/exp_soft/cms/slc5_amd64_gcc434/cms/cmssw-patch/CMSSW_4_2_8_patch7/external/slc5_amd64_gcc434/lib/libCore.so
#3 0x00002adf3ea64cdc in TUnixSystem::DispatchSignals(ESignals) ()
from /opt/exp_soft/cms/slc5_amd64_gcc434/cms/cmssw-patch/CMSSW_4_2_8_patch7/external/slc5_amd64_gcc434/lib/libCore.so
#4
#5 0x00000037d3812861 in _dl_close () from /lib64/ld-linux-x86-64.so.2
#6 0x00000037d380cfa6 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#7 0x00000037d400150d in _dlerror_run () from /lib64/libdl.so.2
#8 0x00000037d400104f in dlclose () from /lib64/libdl.so.2
#9 0x00002adf4129c1b2 in initIfNeeded () at system_io.c:346
#10 0x00002adf4129cbba in system_close (fd=-1) at system_io.c:444
#11 0x00002adf412902d4 in cache_connect (srv=0x1392abb0) at dcap.c:741
#12 0x00002adf41290688 in serverConnect (node=0x1392be90) at dcap.c:565
#13 initControlLine (node=0x1392be90) at dcap.c:302
#14 0x00002adf4129141c in cache_open (node=0x1392be90) at dcap.c:252
#15 0x00002adf41295588 in dc_open (
fname=0x1392c0b8 “dcap://pnfs/roma1.infn.it/data/cms/store/user/cartag/prova.root”, flags=0) at dcap_open.c:284
#16 0x00002adf411362da in TDCacheFile::SysOpen(char const*, int, unsigned int)
()
from /opt/exp_soft/cms/slc5_amd64_gcc434/cms/cmssw-patch/CMSSW_4_2_8_patch7/external/slc5_amd64_gcc434/lib/libDCache.so
#17 0x00002adf41136e3a in TDCacheFile::TDCacheFile(char const*, char const*, char const*, int) ()
from /opt/exp_soft/cms/slc5_amd64_gcc434/cms/cmssw-patch/CMSSW_4_2_8_patch7/external/slc5_amd64_gcc434/lib/libDCache.so
#18 0x000000000040115b in main () at potoalbero.cc:35

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 0x00000037d3812861 in _dl_close () from /lib64/ld-linux-x86-64.so.2
#6 0x00000037d380cfa6 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#7 0x00000037d400150d in _dlerror_run () from /lib64/libdl.so.2
#8 0x00000037d400104f in dlclose () from /lib64/libdl.so.2
#9 0x00002adf4129c1b2 in initIfNeeded () at system_io.c:346
#10 0x00002adf4129cbba in system_close (fd=-1) at system_io.c:444
#11 0x00002adf412902d4 in cache_connect (srv=0x1392abb0) at dcap.c:741
#12 0x00002adf41290688 in serverConnect (node=0x1392be90) at dcap.c:565
#13 initControlLine (node=0x1392be90) at dcap.c:302
#14 0x00002adf4129141c in cache_open (node=0x1392be90) at dcap.c:252
#15 0x00002adf41295588 in dc_open (
fname=0x1392c0b8 “dcap://pnfs/roma1.infn.it/data/cms/store/user/cartag/prova.root”, flags=0) at dcap_open.c:284
#16 0x00002adf411362da in TDCacheFile::SysOpen(char const*, int, unsigned int)
()
from /opt/exp_soft/cms/slc5_amd64_gcc434/cms/cmssw-patch/CMSSW_4_2_8_patch7/external/slc5_amd64_gcc434/lib/libDCache.so
#17 0x00002adf41136e3a in TDCacheFile::TDCacheFile(char const*, char const*, char const*, int) ()
from /opt/exp_soft/cms/slc5_amd64_gcc434/cms/cmssw-patch/CMSSW_4_2_8_patch7/external/slc5_amd64_gcc434/lib/libDCache.so
#18 0x000000000040115b in main () at potoalbero.cc:35

=========================================================
This is my Makefile, i have already included the DCache library:

$Id: Makefile,v 1.8 2010/08/25 08:36:35 rahatlou Exp $

ROOTLIBS = $(shell $(ROOTSYS)/bin/root-config --libs)
ROOTGLIBS = $(shell $(ROOTSYS)/bin/root-config --glibs)

BINFILES = potoalbero.cc

PROGRAMS = $(patsubst %.cc,%,$(BINFILES))

— External configuration ---------------------------------

CC = g++ -Wno-deprecated
CCFLAGS = -g -O3
MFLAGS = -MM
INCLUDES =
WORKDIR = tmp/
LIBDIR = $(WORKDIR)
OBJDIR=$(WORKDIR)/objects/

-------------------------------------------------------------

#ROOFITVER = 5.25.02-cms6
#ROOFITDIR = $(ROOTSYS)/…/…/roofit/$(ROOFITVER)

#ROOFIT_INCLUDE := $(shell cd $(CMSSW_BASE); scram tool info roofitcore | grep INCLUDE= | sed ‘s|INCLUDE=||’)
#ROOFIT_LIBDIR := $(shell cd $(CMSSW_BASE); scram tool info roofitcore | grep LIBDIR= | sed ‘s|LIBDIR=||’)
#ROOFIT_LIBS := $(shell cd $(CMSSW_BASE); scram tool info roofitcore | grep LIB= | sed ‘s|LIB=||’)
#ROOFIT_LIBS += $(shell cd $(CMSSW_BASE); scram tool info roofit | grep LIB= | sed ‘s|LIB=||’)

INCLUDES += -I. -I… -I$(ROOTSYS)/include
#-I$(ROOFIT_INCLUDE)/
ROOTSYS ?= ERROR_RootSysIsNotDefined

EXTRALIBS := -L$(ROOTSYS)/lib -L$(ROOFIT_LIBDIR)/ -lHtml -lMathCore -lGenVector -lMinuit -lEG -lDCache

CC files excluding the binaries

CCFILES=$(filter-out $(BINFILES),$(wildcard *.cc))

List of all object files to build

OLIST=$(patsubst %.cc,$(OBJDIR)/%.o,$(CCFILES))

Implicit rule to compile all classes

$(OBJDIR)/%.o : %.cc
@echo “Compiling $<”
@mkdir -p $(OBJDIR)
@$(CC) $(CCFLAGS) -c $< -o $@ $(INCLUDES)

$(PROGRAMS) : $(OLIST)
@echo “Linking $@”
@$(CC) $(CCFLAGS) $(INCLUDES) $(OLIST)
$(ROOTLIBS) $(EXTRALIBS) -o $(WORKDIR)/$@ $(patsubst %,%.cc,$@)

default : potoalbero

all : potoalbero

Rule to combine objects into a library

#$(LIBFILE): $(OLIST)

@echo “Making $(LIBFILE)”

@rm -f $(LIBFILE)

@ar q $(LIBFILE) $(addprefix $(OBJDIR)/,$(OLIST))

#@ar q $(LIBFILE) $(addprefix $(OBJDIR)/,$(OLIST) $(patsubst %.cc,%.o,$(CINTFILE)))

@ranlib $(LIBFILE)

Useful build targets

#lib: $(LIBFILE)
clean:
rm -Rf $(WORKDIR)/*
@#rm -f $(LIBFILE)
@rm -Rf *.o

veryclean:
rm -Rf $(WORKDIR)

#.PHONY : shlib lib default clean

================================================================
The syntax is correct uscms.org/uscms_at_work/computin … rage.shtml
Could someone help? Thanks, Giovanni

Hi,

Were you able to resolve this problem?

In general we recommend against using directly the concrete TFile implementation and instead to go via the TFile interface and its plugin mechanism:TFile *oldfile = TFile::Open("dcap://cmsrm-se01.roma1.infn.it/pnfs/roma1.infn.it/data/cms/store/user/cartag/prova.root","READ");In particular this avoid having to link your application directly to the plugin libraries.

Cheers,
Philippe.