I got an interesting question about ROOT. This is the part of my python script.
12 new_iso_tight = hist_iso_tight.Clone(“new_iso_tight”) #now only 50 bins or 60 bins
13 # exit()
14 new_iso_tight.SetTitle(new_hists_name_data[i][j])
15 # exit()
First I’m working on lxplus,then
Condition1 :
python3 this script
I got an error " corrupted size vs. prev_size while consolidating"
The root version is 6.34.02
Conditon2 :
setupATLAS
lsetup “root 6.32.08-x86_64-el9-gcc13-opt”
python3 my script
No probelm, the root version is 6.32.08
By using exit() to debug, I found the related code are these two line codes.
I just want to know what’s the difference of these two version root for this related probelm.
With ROOT 6.34, the memory management of of Histograms in PyROOT has changed a bit. Maybe you are accessing an invalid pointer, which could be in this case the hist_iso_tight or the new_iso_tight.
@bellenot is right, a full reproducer would be nice, byt I also don’t understand from your report which line of the two causes the crash actually. Is it hist_iso_tight.Clone() or new_iso_tight.SetTitle()? What happens if you comment out the SetTitle(), will it still crash? And how is the histo_iso_tight created? If it’s not possible to share a reproducer, at least some more code, context and investigation of the problem from your side would be appreciated.
The problem is because you’re having a bunch of TFiles opened, and any newly created histogram is automatically owned by the currently-opened file. At the end of the Python process (in this case your exit()), the ROOT objects are deleted in a random order, and if the histogram is deleted after the file there will be an invalid memory access and a crash.
We’ll avoid this problem in the next ROOT release by telling PyROOT that is should not delete these histograms created by Clone() itself.
For now, the workaround is to manually unset the owning directory of these histograms: