Re: Severe problem with PyRoot - file segmentation fault

From: Kevin B. McCarty <kmccarty_at_gmail.com>
Date: Fri, 13 Jun 2008 09:50:38 -0700


Hi James,

I can replicate this (the fact that the histogram is not saved to the file) on Debian "sid" with Python 2.5.2 and ROOT 5.18.00. A couple minor differences are: 1) I don't get the segfault upon exiting Python, and 2) I also don't get any warnings like "class TFile already in TClassTable".

I can also replicate the fact that the TH1F is not saved using the equivalent statements in ROOT 5.18's Cint interface. So if this is a bug, it isn't Python-specific.

However it seems that in either Python or Cint, what you can do is make a call to g.Write() before f.Close(). At least in my tests, this *will* save the histogram into the test file. As to whether the call to g.Write() is supposed to be unnecessary, I will let more knowledgeable people answer.

What the call to g.Write() appears to do is add a key to the file:

>>> f.ls()

TFile**         test.root
 TFile*         test.root
  OBJ: TH1F     testhist        testhist : 0 at: 0x885fe68
>>> g.Write()
268
>>> f.ls()
TFile**         test.root
 TFile*         test.root
  OBJ: TH1F     testhist        testhist : 0 at: 0x885fe68
  KEY: TH1F     testhist;1      testhist

and then upon closing and re-opening the file,

>>> f.ls()

TFile**         test.root
 TFile*         test.root
  KEY: TH1F     testhist;1      testhist
>>> g = TH1F(f.Get("testhist"))
>>> g.GetBinContent(6)
1.0

best regards,

James Jackson wrote:
> Hi,
>
> I am having serious problems with PyRoot on a new SLC4 machine (it's a
> VM but that shouldn't make any difference), with ROOT built from the
> latest production source:
>
> ----------------------------------
> [james_at_slc4vm PdfErrors]$ python
> Python 2.3.4 (#1, Dec 11 2007, 21:18:01)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.

>>>> from ROOT import TFile, TH1F

> Warning in <TClassTable::Add>: class TFile already in TClassTable
> ...many more of these...
> Warning in <TClassTable::Add>: class TViewer3DPad already in TClassTable
>>>> f = TFile("test.root", "recreate")
>>>> g = TH1F("testhist", "testhist", 10, 0, 10)
>>>> g.Fill(5)

> 6
>>>> f.ls()

> TFile** test.root
> TFile* test.root
> OBJ: TH1F testhist testhist : 0 at: 0x9a9e280
>>>> f.Close()
>>>> <here do Ctrl+D>

> Segmentation fault
> ----------------------------------
>
> Subsequently inspecting the root file shows it to be empty:
>
> ----------------------------------
> [james_at_slc4vm PdfErrors]$ python
> Python 2.3.4 (#1, Dec 11 2007, 21:18:01)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from ROOT import TFile

> Warning in <TClassTable::Add>: class TFile already in TClassTable
> ...many more of these
> Warning in <TClassTable::Add>: class TViewer3DPad already in TClassTable
>>>> f = TFile("test.root")
>>>> f.ls()

> TFile** test.root
> TFile* test.root
> ----------------------------------
>
> Could anybody suggest what is going wrong?
>
> [james_at_slc4vm PdfErrors]$ uname -a
> Linux slc4vm.local 2.6.9-67.0.15.EL.cern #1 Thu May 8 11:11:47 CEST 2008
> i686 i686 i386 GNU/Linux
>
> Regards,
> James.
>
-- 
Kevin B. McCarty <kmccarty_at_gmail.com>
WWW: http://www.starplot.org/
WWW: http://people.debian.org/~kmccarty/
GPG: public key ID 4F83C751
Received on Fri Jun 13 2008 - 18:50:48 CEST

This archive was generated by hypermail 2.2.0 : Fri Jun 13 2008 - 23:50:01 CEST