Skip to content
Snippets Groups Projects
  • Enric Tejedor Saavedra's avatar
    413bd994
    [ROOT-9809] Only invoke Python C API if Python is initialized · 413bd994
    Enric Tejedor Saavedra authored
    If libPyROOT is loaded with gSystem->Load, the static
    initialization block in TMemoryRegulator.cxx is executed and
    ends up invoking PyCFunction_New, which causes a crash from
    Python 3.7. The crash is due to Python not being initialized.
    This also happens when using TPython from C++, since Python
    has not	been initialized when TPython is used.
    
    Note that when loading libPyROOT from ROOT.py, which is what
    happens when someone uses PyROOT, the Python interpreter already
    exists and is initialized, so invoking PyCFunction_New does not
    crash.
    
    This fix moves the creation of gObjectEraseCallback away from
    the static block in TMemoryRegulator in order to prevent the
    issue described above.
    413bd994
    History
    [ROOT-9809] Only invoke Python C API if Python is initialized
    Enric Tejedor Saavedra authored
    If libPyROOT is loaded with gSystem->Load, the static
    initialization block in TMemoryRegulator.cxx is executed and
    ends up invoking PyCFunction_New, which causes a crash from
    Python 3.7. The crash is due to Python not being initialized.
    This also happens when using TPython from C++, since Python
    has not	been initialized when TPython is used.
    
    Note that when loading libPyROOT from ROOT.py, which is what
    happens when someone uses PyROOT, the Python interpreter already
    exists and is initialized, so invoking PyCFunction_New does not
    crash.
    
    This fix moves the creation of gObjectEraseCallback away from
    the static block in TMemoryRegulator in order to prevent the
    issue described above.