Segmentation violation for TChain for ROOT5.18

#include "TChain.h"
#include "TH1F.h"
#include "TString.h"
#include <iostream>

using namespace std;

int main()
{
	const char* rootfiledir="/media/Data2/rootfiles";

	TChain* ch=new TChain("T","Tree");
	ch->Add(Form("%s/1327.root",rootfiledir));
	ch->Add(Form("%s/1327_1.root",rootfiledir));
	ch->Add(Form("%s/1327_2.root",rootfiledir));
	ch->Add(Form("%s/1327_3.root",rootfiledir));

	cout<<ch->LoadTree(0)<<endl;
//[1]
	cout<<ch->GetEntries("(DL.evtypebits&(1<<3))>0")<<endl;
	TH1F* h1_th=new TH1F("h1_th","h1_th",400,-0.05,0.05);
//[2]
	ch->Project("h1_th","L.gold.th");
	Double_t TC_Theta0=h1_th->GetMean();
	cout<<"DEBUG-->TC_Theta0="<<TC_Theta0<<endl;

	delete h1_th;
	delete ch;
	return 0;
}

To run this,

g++  -O2 -Wall -fPIC -pthread -m32 -I/usr/include/root -c main.C
g++ -O2 -m32 main.o -L/usr/lib/root -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lz -pthread -lm -ldl -rdynamic  -o main
./main

The problem is [ul]
Running code with [1] or [2] separately is fine.[/ul]
[ul]Running code with [1] and [2] together gives “Break Segmentation violation” error.
0
1001957

*** Break *** segmentation violation
Attaching to program: /proc/5770/exe, process 5770
[Thread debugging using libthread_db enabled]
[New Thread 0xb60d76c0 (LWP 5770)]
0xb7f6e430 in __kernel_vsyscall ()
error detected on stdin
The program is running. Quit anyway (and detach it)? (y or n) [answered Y; input not from terminal]
Detaching from program: /proc/5770/exe, process 5770

[/ul]
I use gdb to backtrace the code

Any idea why?

My OS info:
ubuntu 8.10
Linux 2.6.27-14-generic
g++ 4.3.2
ROOT 5.18/00b

Thanks in advance.

Hi,

This problem has been fixed in root v5.20/00 and above.

To work around the problem in v5.18, you can use//[1] cout<<ch->GetEntries("(py)>0")<<endl; ch->SetNotify(0); TH1F* h1_th=new TH1F("h1_th","h1_th",400,-0.05,0.05);

Cheers,
Philippe.

Great. It works.
Thanks a lot.