Output could be produced but here is a long list of errors

Dear PyROOT expert:

My script could produce the correct result, but there is a long list of error message, any idea with it?

*** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library “/lib/tls/libthread_db.so.1”.
Attaching to program: /proc/13622/exe, process 13622
[Thread debugging using libthread_db enabled]
[New Thread -1208359232 (LWP 13622)]
[New Thread -1212249184 (LWP 13628)]
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
0x0069b7a2 in _dl_sysinfo_int80 ()
from /lib/ld-linux.so.2
Thread 2 (Thread -1212249184 (LWP 13628)):
#0 0x0069b7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x00924e1f in sem_wait@GLIBC_2.0 () from /lib/tls/libpthread.so.0
#2 0x0059bf5b in PyThread_acquire_lock () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#3 0x00575a80 in PyEval_RestoreThread () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#4 0x0094c04d in inittime () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/python2.3/lib-dynload/timemodule.so
#5 0x00544599 in PyCFunction_Call () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#6 0x0057a159 in _PyEval_SliceIndex () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#7 0x0057bc9b in PyEval_EvalCodeEx () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#8 0x00533a18 in PyFunction_SetClosure () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#9 0x0051edd7 in PyObject_Call () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#10 0x00579603 in _PyEval_SliceIndex () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#11 0x0057b575 in _PyEval_SliceIndex () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#12 0x0057bc9b in PyEval_EvalCodeEx () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#13 0x00533a18 in PyFunction_SetClosure () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#14 0x0051edd7 in PyObject_Call () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#15 0x00526d9b in PyMethod_New () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#16 0x0051edd7 in PyObject_Call () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#17 0x00575e08 in PyEval_CallObjectWithKeywords () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#18 0x0059f524 in _PyObject_GC_Del () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#19 0x009205cc in start_thread () from /lib/tls/libpthread.so.0
#20 0x00780fae in clone () from /lib/tls/libc.so.6

Thread 1 (Thread -1208359232 (LWP 13622)):
#0 0x0069b7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x0074057b in __waitpid_nocancel () from /lib/tls/libc.so.6
#2 0x006e9819 in do_system () from /lib/tls/libc.so.6
#3 0x006e9b91 in system () from /lib/tls/libc.so.6
#4 0x00926b8d in system () from /lib/tls/libpthread.so.0
#5 0x00f5746b in TUnixSystem::Exec () from /home/qing/download/root/lib/libCore.so
#6 0x00f5cef5 in TUnixSystem::StackTrace () from /home/qing/download/root/lib/libCore.so
#7 0x00f59b3a in TUnixSystem::DispatchSignals () from /home/qing/download/root/lib/libCore.so
#8 0x00f59bc8 in SigHandler () from /home/qing/download/root/lib/libCore.so
#9 0x00f58e0d in sighandler () from /home/qing/download/root/lib/libCore.so
#10
#11 0x09e94158 in ?? ()
#12 0x00d31d99 in TMultiLayerPerceptron::~TMultiLayerPerceptron$delete () from /home/qing/download/root/lib/libMLP.so
#13 0x00d43c54 in ROOT::delete_TMultiLayerPerceptron () from /home/qing/download/root/lib/libMLP.so
#14 0x00f29380 in TClass::Destructor () from /home/qing/download/root/lib/libCore.so
#15 0x00177355 in PyROOT::op_dealloc_nofree () from /home/qing/download/root/lib/libPyROOT.so
#16 0x001775e1 in PyROOT::(anonymous namespace)::op_dealloc () from /home/qing/download/root/lib/libPyROOT.so
#17 0x005541de in PyType_GenericNew () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#18 0x00531a0e in _PyFloat_Unpack8 () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#19 0x0057b594 in _PyEval_SliceIndex () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#20 0x0057bc9b in PyEval_EvalCodeEx () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#21 0x0057bf55 in PyEval_EvalCode () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#22 0x005964f5 in PyErr_Display () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#23 0x00597755 in PyRun_SimpleFileExFlags () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#24 0x0059881a in PyRun_AnyFileExFlags () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#25 0x0059d8c7 in Py_Main () from /afs/cern.ch/project/gd/LCG-share/3.1.25-0/external/usr/lib/libpython2.3.so.1.0
#26 0x080485ba in main ()

I used MLP in my scrip:

    mlp1 = TMultiLayerPerceptron("price0,price1,price2,price3,price4:10:price5",milk)
    mlpa = TMLPAnalyzer(mlp1)
    mlpa.GatherInformations()
    mlpa.CheckNetwork()
    mlp1.LoadWeights("milk.txt")



    for i in range(len(list5)):
            params = array( 'd', [0.]*5 )
            params[0] = list0[i]
            params[1] = list1[i]
            params[2] = list2[i]
            params[3] = list3[i]
            params[4] = list4[i]
            val = mlp1.Evaluate(0,params)
            print val
    fout.Close()

Thanks,Gang

Gang,

the TMultiLayerPerceptron is deleted twice. From the snippet of code that you present it isn’t clear why. Especially since in normal heuristics mode the “TMLPAnalyzer(mlp1)” call should drop python ownership.

Could you post the whole script and the context in which it is run?

Cheers,
Wim

Dear wlav:

Thanks for the hint. Enclosed are the 2 files.
data.txt (14.7 KB)
train.py (2.05 KB)

Gang,

so the problem is not a memory sharing mismatch between python and C++ as I originally thought, but it is fully on the C++ side.

The TMultiLayerPerceptron objects create TEventLists of which the TFile claims ownership. Once the file closes, the TEventLists get destroyed, but the TMultiLayerPerceptron isn’t done with them nor has it given up ownership.

One way around this, is to delete mlp and mlp1 just before closing the output file:

del mlp, mlp1 fout.Close()
It isn’t clear to me, however, how this code normally is supposed to work …

Cheers,
Wim