Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-9890

Memory error when using Roofit objects as attributes of a class in python

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Low
    • Resolution: Duplicate
    • 6.14/04
    • 6.16/00, 6.14/08
    • PyROOT, RooFit/RooStats
    • None
    • /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt

      ROOT 6.14/04

    Description

      Hi ! I recently noticed some strange behaviours when using some Roofit objects in python. For instance, when a RooWorkspace is set as an attribute of a class, it can trigger a memory error (for instance when importing stuff inside the RooWorkspace)

       

      Here is a minimal non working example:

      import ROOT as r
      class Dummy:
       def __init__(self):
        self.wk = r.RooWorkspace("wk")
        self.wk.factory("my_var[1,0,3]")
        ds = r.RooDataSet( "ds", "ds", self.wk.allVars() )
        getattr( self.wk, "import" ) (ds)
        self.wk.Print()
       
      my_dummy = Dummy()
      

      The memory error is thrown at the end:

      *** glibc detected *** python: free(): invalid pointer: 0x0000000004743a2c ***
      ======= Backtrace: =========
      /lib64/libc.so.6[0x3479275e5e]
      /lib64/libc.so.6[0x3479278cad]
      /cvmfs/sft.cern.ch/lcg/releases/ROOT/6.14.04-38745/x86_64-slc6-gcc62-opt/lib/libRooFitCore.so(_ZN13RooL
      inkedList6DeleteEPKc+0x23)[0x7fd24602d9d3]
      /cvmfs/sft.cern.ch/lcg/releases/ROOT/6.14.04-38745/x86_64-slc6-gcc62-opt/lib/libRooFitCore.so(_ZN12RooW
      orkspaceD2Ev+0x3d)[0x7fd246102fed]
      /cvmfs/sft.cern.ch/lcg/releases/ROOT/6.14.04-38745/x86_64-slc6-gcc62-opt/lib/libRooFitCore.so(_ZN12RooW
      orkspaceD0Ev+0x9)[0x7fd246103269]
      /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt/lib/libCore.so(_ZN6TClass10DestructorE
      Pvb+0x31)[0x7fd254991551]
      /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt/lib/libPyROOT.so(_ZN6PyROOT17op_deallo
      c_nofreeEPNS_11ObjectProxyE+0x1b7)[0x7fd25835a7a7]
      /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt/lib/libPyROOT.so(+0x69819)[0x7fd25835a
      819]
      /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt/lib/libpython3.6m.so.1.0(+0xed4cc)[0x7
      fd25ecaa4cc]
      /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt/lib/libpython3.6m.so.1.0(+0xc70d7)[0x7
      fd25ec840d7]
      /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt/lib/libpython3.6m.so.1.0(+0xed541)[0x7
      fd25ecaa541]
      /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt/lib/libpython3.6m.so.1.0(PyDict_SetIte
      m+0x397)[0x7fd25ec882a7]
      /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt/lib/libpython3.6m.so.1.0(_PyModule_Cle
      arDict+0x228)[0x7fd25ec97b88]
      /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt/lib/libpython3.6m.so.1.0(PyImport_Clea
      nup+0x3c4)[0x7fd25ed49174]
      /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt/lib/libpython3.6m.so.1.0(Py_FinalizeEx
      +0x6b)[0x7fd25ed57fdb]
      /cvmfs/sft.cern.ch/lcg/views/LCG_94python3/x86_64-slc6-gcc62-opt/lib/libpython3.6m.so.1.0(Py_Main+0x6b9
      )[0x7fd25ed796e9] 
      python(main+0x177)[0x400a97]
      /lib64/libc.so.6(__libc_start_main+0x100)[0x347921ed20]
      python[0x400b51] 
      ======= Memory map: ========
      00400000-00401000 r-xp 00000000 00:26 4153050 /exp/LHCb/fdesse/ewp-Bd2Kstee-AngAna/venv/angAna/bin/python
      00601000-00602000 r--p 00001000 00:26 4153050 /exp/LHCb/fdesse/ewp-Bd2Kstee-AngAna/venv/angAna/bin/python
      00602000-00603000 rw-p 00002000 00:26 4153050 /exp/LHCb/fdesse/ewp-Bd2Kstee-AngAna/venv/angAna/bin/python
      00f13000-04a3c000 rw-p 00000000 00:00 0 [heap]
      3478e00000-3478e20000 r-xp 00000000 08:02 8300 /lib64/ld-2.12.so
      3479020000-3479021000 r--p 00020000 08:02 8300 /lib64/ld-2.12.so
      3479021000-3479022000 rw-p 00021000 08:02 8300 /lib64/ld-2.12.so
      

      I also witnessed a similar bug using RooMCStudy in the same fashion.

      A temporary workaroud proposed by Chris Burr is to add the line:

      atexit.register(self.wk.Delete)
      

      inside the definition of the python class to force RooFit to clean up. It would probably be better if RooFit would do it properly in the first place I guess.

      cheers,

      Fabrice

      Attachments

        Issue Links

          Activity

            People

              shageboe Stephan Hageboeck
              fadesse Fabrice Desse (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Actual End: