Segmentation violation at TPad::Print("*.gif") for THStack

From: Hajime Nanjo <nanjyo_at_icepp.s.u-tokyo.ac.jp>
Date: Mon, 03 Oct 2005 17:50:10 +0900


Dear ROOTers,

A segmentation vaiolation is occured at
TPad::Print("*.gif") in a batch mode for ROOT v4.04.02.

A script, "hstack.C", includes THStack object and gPad->Print("hstack.gif").
When it is run from CINT as ".x hstack.C", there is no problem, but
when it is run in batch mode as "root -b hstack.C", a segmentation vaiolation is occured.
(For the case of ROOT v4.02, it just prints warning message and  give up creating a gif file.)

Could you please fix to avoid the segmentation violation?

Best Regards,
Hajime


More detailed explanations are described below. (ROOT version, source code, error messages, behavior in some cases)


  1. ROOT version is v4.04.02 in slc3
    lxplus016:~$ uname -a Linux lxplus016.cern.ch 2.4.21-32.0.1.EL.cernsmp #1 SMP Thu May 26 12:29:50 CEST 2005 i686 i686 i386 GNU/Linux lxplus016:~$ gcc -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-52) lxplus016:~$ echo $ROOTSYS /afs/cern.ch/sw/root/v4.04.02/slc3_gcc3.2.3/root lxplus016:~$

2. source code

//
{

   THStack *hs = new THStack("hs","test stacked histograms");    TH1F *h1 = new TH1F("h1","test hstack",100,-4,4);

   h1->FillRandom("gaus",20000);
   h1->SetFillColor(kRed);
   h1->SetMarkerStyle(21);
   h1->SetMarkerColor(kRed);
   hs->Add(h1);

   TH1F *h2 = new TH1F("h2","test hstack",100,-4,4);
   h2->FillRandom("gaus",15000);
   h2->SetFillColor(kBlue);
   h2->SetMarkerStyle(21);
   h2->SetMarkerColor(kBlue);
   hs->Add(h2);

   TH1F *h3 = new TH1F("h3","test hstack",100,-4,4);
   h3->FillRandom("gaus",10000);
   h3->SetFillColor(kGreen);
   h3->SetMarkerStyle(21);
   h3->SetMarkerColor(kGreen);
   hs->Add(h3);
   

   hs->Draw();
   gPad->Print("hstack.gif");
   gPad->Print("hstack.ps");
}



3. error messages

root [0]
Processing hstack.C...
<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
4. behavior in some cases
case 1 : root [0] .x hstack.C     OK
case 2 : root -b hstack.C         Segmentation violation
case 3 : if only TH1  is used in a script, there is no problem.
for example,
//
{
  TH1F *h1 = new TH1F("h1","test hstack",100,-4,4);
  h1->FillRandom("gaus",20000);
  h1->SetFillColor(kRed);
  h1->SetMarkerStyle(21);
  h1->SetMarkerColor(kRed);
  h1->Draw();

  gPad->Print("hsimple.gif");
  gPad->Print("hsimple.ps");
} Received on Mon Oct 03 2005 - 10:50:21 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:12 MET