ROOT Version: 6.22/00
Platform: macOS 10.15.5
Compiler: Apple clang version 11.0.3 (clang-1103.0.32.62)
When I use the Geom library in PyROOT in the following short test script, I get a segmentation fault presumably due to conflict between the Python garbage collection and the automatic memory deletion in the Geom library.
Could you tell me a recommended way to fix this script?
import ROOT
def makeTheWorld():
manager = ROOT.TGeoManager("manager", "manager")
matVacuum = ROOT.TGeoMaterial("matVacuum", 0, 0, 0)
vacuum = ROOT.TGeoMedium("Vacuum", 1, matVacuum)
world = manager.MakeBox("world", vacuum, 1, 1, 1)
manager.SetTopVolume(world)
return manager
def test():
manager = makeTheWorld()
smallbox = manager.MakeBox("smallbox", manager.GetMedium("Vacuum"),
0.1, 0.1, 0.1)
manager.GetTopVolume().AddNode(smallbox, 1)
manager.CloseGeometry()
test()
$ python3 test.py
Info in <TGeoManager::TGeoManager>: Geometry manager, manager created
(snip)
Info in <TGeoManager::CloseGeometry>: ----------------modeler ready----------------
Error in <THashList::Delete>: A list is accessing an object (0x7febd6539080) already deleted (list name = THashList)
Python(36663,0x1045b2dc0) malloc: tiny_free_list_remove_ptr: Internal invariant broken (next ptr of prev): ptr=0x7febd65523c0, prev_next=0x207febd65523c0
Python(36663,0x1045b2dc0) malloc: *** set a breakpoint in malloc_error_break to debug
zsh: abort python3 test.py
$ python3 test.py
Info in <TGeoManager::TGeoManager>: Geometry manager, manager created
(snip)
Info in <TGeoManager::CloseGeometry>: ----------------modeler ready----------------
*** Break *** segmentation violation
[/usr/local/root-6.22.00/obj/lib/libCore.so] TUnixSystem::DispatchSignals(ESignals) (no debug info)
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[/usr/local/root-6.22.00/obj/lib/libCore.so] TFunction::~TFunction() (no debug info)
[/usr/local/root-6.22.00/obj/lib/libcppyy_backend3_7.so] (anonymous namespace)::ApplicationStarter::~ApplicationStarter() (no debug info)
[/usr/lib/system/libsystem_c.dylib] __cxa_finalize_ranges (no debug info)
[/usr/lib/system/libsystem_c.dylib] exit (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)
[<unknown binary>] (no debug info)
*** Break *** segmentation violation
[/usr/local/root-6.22.00/obj/lib/libCore.so] TUnixSystem::DispatchSignals(ESignals) (no debug info)
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[/usr/local/root-6.22.00/obj/lib/libCore.so] TFunction::~TFunction() (no debug info)
[/usr/local/root-6.22.00/obj/lib/libcppyy_backend3_7.so] (anonymous namespace)::ApplicationStarter::~ApplicationStarter() (no debug info)
[/usr/lib/system/libsystem_c.dylib] __cxa_finalize_ranges (no debug info)
[/usr/lib/system/libsystem_c.dylib] exit (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)
[<unknown binary>] (no debug info)