Python script runs, but has a seg violation during cleanup

Hi,

 I've got a PyRoot script that runs successfully (i.e., it does what I want), but then instead of finishing gracefully, it gives a segmentation violation.
cplager@njhu04> ./problem.py
Info in <TCanvas::Print>: file TopPull.png has been created
Done.

 *** Break *** segmentation violation
Attaching to program: /mnt/autofs/cdf/cdf.code/cdfsoft/products/python/v2_4_5/Linux+2/bin/python, process 10565
[New Thread -1208572224 (LWP 10565)]
done.
done.
done.
done.
0x00b3f7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1  0x00be380b in __waitpid_nocancel () from /lib/tls/libc.so.6
Cannot access memory at address 0x1
cplager@njhu04> which root
/cdf/code/cdfsoft/products/root/v5_22_00GCC_3_4_3/Linux+2.6/bin/root
cplager@njhu04> which python
/cdf/code/cdfsoft/products/python/v2_4_5/Linux+2/bin/python

Script and root file attached.

Cheers,
Charles
PEs_seed001.root (24.5 KB)
problem.py.txt (430 Bytes)

Charles,

there’s a known ownership problem w/ TFile and TChain (not with TTree, or any of the other file contents), if one or the other (or both) is owned by python at the global scope. Although fixed in HEAD, the recommendation for older releases is to remove the TChain on the python side before shutdown, or:del chainin your code. Alternatively, putting the code in a function, so that ‘chain’ becomes a local rather than global variable and gets cleaned up automatically after the function exits, works as well.

HTH,
Wim

Thanks for the explanation. I’ll delete it as you suggested.
Cheers, Charles