Hi,
Please note that TClass does not support virtual inheritance. In most case you ought to be able to use composition instead of inheritance to accomplish the same effect.
Cheers,
Philippe.
On 8/3/10 6:52 PM, OKUMURA, Akira wrote:
> Hello ROOTers,
>
> When I use a ROOT based class in PyROOT, I get a seg fault. The class derives from TNamed but I use "public virtual TNamed" instead of "public TNamed" to avoid multiple inheritance. I would like to know how to work around this problem. I am using Python 2.6.1 and GCC 4.2.1 on OS X 10.6.4 and ROOT 5.27.02.
>
> The attached is a minimum example. The following are ROOT and PyROOT examples.
>
> === ROOT interpreter (OK) ===
> [oxon_at_kusu ~]$ root
> root [0] .L test.C+
> root [1] TMyClass my
> root [2] my.GetNamed()->SetName("name")
> root [3] my.GetNamed()->GetName()
> (const char* 0x103b54e18)"name"
>
> === Python interpreter (NG) ===
> [oxon_at_kusu ~]$ python
> Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
> [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>
>>>> import ROOT
>>>> ROOT.gROOT.ProcessLine(".L test.C+")
>>>>
> 0L
>
>>>> my = ROOT.TMyClass()
>>>> my.GetNamed()
>>>>
> *** Break *** segmentation violation
>
>
>
> ===========================================================
> There was a crash.
> This is the entire stack trace of all threads:
> ===========================================================
>
> Thread 2 (process 35270):
> #0 0x00007fff83e14eb6 in __semwait_signal ()
> #1 0x00007fff83e18cd1 in _pthread_cond_wait ()
> #2 0x00000001000adcea in PyThread_acquire_lock ()
> #3 0x00000001000852e4 in PyEval_RestoreThread ()
> #4 0x00000001048c5ff5 in _PyTime_DoubleToTimet ()
> #5 0x0000000100089187 in PyEval_EvalFrameEx ()
> #6 0x000000010008acce in PyEval_EvalCodeEx ()
> #7 0x000000010002c88f in PyClassMethod_New ()
> #8 0x000000010000aff3 in PyObject_Call ()
> #9 0x000000010008a54e in PyEval_EvalFrameEx ()
> #10 0x00000001000892e1 in PyEval_EvalFrameEx ()
> #11 0x00000001000892e1 in PyEval_EvalFrameEx ()
> #12 0x000000010008acce in PyEval_EvalCodeEx ()
> #13 0x000000010002c8e1 in PyClassMethod_New ()
> #14 0x000000010000aff3 in PyObject_Call ()
> #15 0x000000010001a9df in PyClass_New ()
> #16 0x000000010000aff3 in PyObject_Call ()
> #17 0x00000001000849db in PyEval_CallObjectWithKeywords ()
> #18 0x00000001000b1db6 in initthread ()
> #19 0x00007fff83e13456 in _pthread_start ()
> #20 0x00007fff83e13309 in thread_start ()
>
> Thread 1 (process 35270):
> #0 0x00007fff83e57c90 in wait4 ()
> #1 0x00007fff83e6c23e in system ()
> #2 0x00000001011c4488 in TUnixSystem::StackTrace ()
> #3 0x00000001011c1e0a in TUnixSystem::DispatchSignals ()
> #4<signal handler called>
> #5 0x0000000101013aa7 in PyROOT::TMemoryRegulator::RegisterObject ()
> #6 0x000000010102ab98 in PyROOT::BindRootObject ()
> #7 0x0000000101016df2 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::CallSafe ()
> #8 0x0000000101016fa6 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::Execute ()
> #9 0x0000000101014815 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::operator() ()
> #10 0x000000010101bd12 in PyROOT::(anonymous namespace)::mp_call ()
> #11 0x000000010000aff3 in PyObject_Call ()
> #12 0x000000010008a51a in PyEval_EvalFrameEx ()
> #13 0x000000010008acce in PyEval_EvalCodeEx ()
> #14 0x000000010008ad61 in PyEval_EvalCode ()
> #15 0x00000001000a265a in Py_CompileString ()
> #16 0x00000001000a44dd in PyRun_InteractiveOneFlags ()
> #17 0x00000001000a4615 in PyRun_InteractiveLoopFlags ()
> #18 0x00000001000a4685 in PyRun_AnyFileExFlags ()
> #19 0x00000001000b0286 in Py_Main ()
> #20 0x0000000100000e6c in start ()
> ===========================================================
>
>
> The lines below might hint at the cause of the crash.
> If they do not help you then please submit a bug report at
> http://root.cern.ch/bugs. Please post the ENTIRE stack trace
> from above as an attachment in addition to anything else
> that might help us fixing this issue.
> ===========================================================
> #5 0x0000000101013aa7 in PyROOT::TMemoryRegulator::RegisterObject ()
> #6 0x000000010102ab98 in PyROOT::BindRootObject ()
> #7 0x0000000101016df2 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::CallSafe ()
> #8 0x0000000101016fa6 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::Execute ()
> #9 0x0000000101014815 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::operator() ()
> #10 0x000000010101bd12 in PyROOT::(anonymous namespace)::mp_call ()
> #11 0x000000010000aff3 in PyObject_Call ()
> #12 0x000000010008a51a in PyEval_EvalFrameEx ()
> #13 0x000000010008acce in PyEval_EvalCodeEx ()
> #14 0x000000010008ad61 in PyEval_EvalCode ()
> #15 0x00000001000a265a in Py_CompileString ()
> #16 0x00000001000a44dd in PyRun_InteractiveOneFlags ()
> #17 0x00000001000a4615 in PyRun_InteractiveLoopFlags ()
> #18 0x00000001000a4685 in PyRun_AnyFileExFlags ()
> #19 0x00000001000b0286 in Py_Main ()
> #20 0x0000000100000e6c in start ()
> ===========================================================
>
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in<module>
> SystemError: problem in C++; program state has been reset
>
> Regards,
>
> --
> OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu}
> Institute of Space and Astronautical Science (ISAS/JAXA)
> Now at KIPAC/SLAC/Stanford
> Varian Physics #306
> 382 Via Pueblo Mall, MC 406 Stanford, CA94305
> TEL 650-736-0971/FAX 650-724-5065
> Skype : okumura.akira
>
Received on Wed Aug 04 2010 - 18:59:29 CEST
This archive was generated by hypermail 2.2.0 : Wed Aug 04 2010 - 23:50:01 CEST