TGFileDialog and possible memory corruption

Hello,

I’ve been using the following function in pyROOT for a long time with success:

def GetFileNameFromDialog(mode=0):
	if mode==0: mode_str = "kFDSave"
	elif mode==1: mode_str = "kFDOpen"
	fi = ROOT.gROOT.ProcessLine("TGFileInfo* fi = new TGFileInfo; new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), "+mode_str+", fi); fi;")
	myfi = ROOT.BindObject(fi, ROOT.TGFileInfo)
	ROOT.SetOwnership(myfi, True)
	fn = myfi.fFilename
	#return myfi.fFilename
	return fn, myfi, fi

Recently I made adjustements in my code replacing TTrees by TChain and I think the above function corrupts the memory in some way, since, as you can see, it has nothing directly to do with the Trees that I am using in my code.

In general, when my code works on a chain containing a single Tree, everything is OK. When a chain contains more, the chain gets corrupted just after calling this function:

Error in <TFile::TFile>: file allpackets-TA-ACQUISITION-20150918-041406-gaintable_20150516.txt-Cosmic20deg0414.root does not exist

the file of course exists and was displayed just before opening the file dialog. I can’t give a working example, so I need to ask - is there anything obvious in the function shown above, that could corrupt the memory? I am using ROOT 5.34.36

Hi,

Looks good to me… What does valgrind --num-callers=50 --track-origins=yes say? Please make use of both suppression files in ROOTSYS/etc/valgrind*.supp

Cheers, Axel.

Valgrind does not display any errors, but I have a suspicion what may be wrong.

If I open the file from the same directory as my TChained ROOT files, everything is OK. However, when I open a file from other directory, described situation happens. I suspect, that some working directory for ROOT changes - the directory in which the TChain assumes the ROOT files are. It is a little bit strange, since the file to which I get the link with the dialog and then open is not a ROOT file…