I have been having an issue using ROOT.TMVA.PyMethodBase.PyInitialize() in a program. My program ends in a Segmentation Fault after successfully completing the rest of the program. For example, for the following program:
import ROOT
from TIMBER.Tools.Common import *
from TIMBER.Analyzer import *
import numpy as np
ROOT.TMVA.PyMethodBase.PyInitialize()
print("success")
The output is:
success
Segmentation fault (core dumped)
Similar outputs happen for more complicated programs with more than just a print statement. In that case, all the lines of the program run as expected, but the program will still end in a Segmentation Fault.
In my testing, I have found that there will be no seg fault if either:
i remove the line ROOT.TMVA.PyMethodBase.PyInitialize()
i remove all imports except for import ROOT
Neither of these options are practical, since I need all of the imports listed in my example above and I also need to be able to use ROOT.TMVA.PyMethodBase.PyInitialize()
Any guidance on the cause of this error and how it can be fixed would be much appreciated.
Some details about my setup:
Root Version: 6.32.02
Python Version: 3.9.18
Numpy Version: 1.21.0
thanks for the post. I am sorry to read ROOT does not work out of the box for you.
I am adding the expert in the loop @moneta .
Could you also point us out to the repository and installation procedure for TIMBER?
Sorry for your problem, strange you have this crash, I don’t remember having seen this before, maybe it caused by come conflicts. Can you also tell us what is your architecture (type of Linux or MacOS), how did you build/install ROOT and what did you do to setup your running environment to use ROOT ?
I have a bit of an unconventional installation procedure for TIMBER. For the project I am working on I needed to build TIMBER outside of CMSSW, so I needed to manually change its Makefile. I will also add that I still get the error without the TIMBER import lines.
If the only two imports are ROOT and numpy, the same problem still occurs. I probably should have omitted the TIMBER imports from my original post for that reason.
Still, if my TIMBER installation is at all helpful, here it is:
I used this repository: GitHub - JHU-Tools/TIMBER
and cloned it using the line git clone git@github.com:JHU-Tools/TIMBER.git
Then I installed boostlib and set my boost path to that installation. I then edited the Makefile for TIMBER to point to my boostlib installation and to not rely on any CMSSW paths. Here are the specific edits I made:
Add -I/../boostlib/boost_install/include to the INCLUDE variable
Add -L/../boostlib/boost_install/lib to the LIBS variable
Remove the lines that read:
ifndef CMSSW_VERSION
CPP_FILES:=$(filter-out $(JME_FILES), $(CPP_FILES))
else
CMSSW:=$(CMSSW) -l CondFormatsJetMETObjects -l JetMETCorrectionsModules
endif
And instead put:
CPP_FILES:=$(filter-out $(JME_FILES), $(CPP_FILES))
After that I built TIMBER with source setup.sh and was able to run a handful of example programs successfully.
I am using Linux with a 64-bit architecture (specifically the output of the arch command is x86_64)
Before building ROOT I made a python virtual environment called timber-env that uses python3.9 and I installed numpy version 1.21.0 in this environment. For building ROOT, I got the source code using git clone --branch latest-stable --depth=1 https://github.com/root-project/root.git root_src and I used cmake to build it.
I ran cmake -Dtmva-sofie=ON -DPYTHON_EXECUTABLE=/../timber-env/bin/python3.9 -DCMAKE_INSTALL_PREFIX=../root_install ../root_src from inside a seperate build directory. Then I used source root_install/bin/thisroot.sh
Every time I need to run something using this setup, I do
Hi,
If I have understood correctly, if you remove import TIMBER, it will work fine, correct?
There could then be a conflict issue between TIMBER and ROOT PyMVA. Can you then try to do import TIMBER after calling ROOT.TMVA.PyMethodBase.PyInitialize()?
Also if you show the back trace obtained using gdb could be useful.
It runs without error but if any of the following lines are with import ROOT there will be an error:
import numpy as np
from TIMBER.Tools.Common import *
from TIMBER.Analyzer import *
I tried what you suggested, also putting import numpy below ROOT.TMVA.PyMethodBase.PyInitialize() and that has allowed the prograam to run without error! My program now looks like this:
import ROOT
ROOT.TMVA.PyMethodBase.PyInitialize()
import numpy as np
from TIMBER.Tools.Common import *
from TIMBER.Analyzer import *
print("success")
and runs as expected
As for the stack trace, when my program looks like this:
import ROOT
import numpy as np
from TIMBER.Tools.Common import *
from TIMBER.Analyzer import *
ROOT.TMVA.PyMethodBase.PyInitialize()
print("success")
The stack trace is the following:
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
Thread 5 (Thread 0x7fa6bffff640 (LWP 3048094) "python3.11"):
#0 0x00007fa6cf48679a in __futex_abstimed_wait_common () from /lib64/libc.so.6
#1 0x00007fa6cf4892a4 in pthread_cond_timedwait
GLIBC_2.3.2 () from /lib64/libc.so.6
#2 0x00007fa6cf9a5f1a in take_gil () from /lib64/libpython3.11.so.1.0
#3 0x00007fa6cf9beae6 in PyEval_RestoreThread () from /lib64/libpython3.11.so.1.0
#4 0x00007fa6cfa5effe in acquire_timed () from /lib64/libpython3.11.so.1.0
#5 0x00007fa6cfa5edbf in lock_PyThread_acquire_lock () from /lib64/libpython3.11.so.1.0
#6 0x00007fa6cf9deabd in method_vectorcall_VARARGS_KEYWORDS () from /lib64/libpython3.11.so.1.0
#7 0x00007fa6cf9cff1c in PyObject_Vectorcall () from /lib64/libpython3.11.so.1.0
#8 0x00007fa6cf9c0c9e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#9 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#10 0x00007fa6cf9f94f2 in method_vectorcall () from /lib64/libpython3.11.so.1.0
#11 0x00007fa6cfaa86cc in thread_run () from /lib64/libpython3.11.so.1.0
#12 0x00007fa6cfa76528 in pythread_wrapper () from /lib64/libpython3.11.so.1.0
#13 0x00007fa6cf489c02 in start_thread () from /lib64/libc.so.6
#14 0x00007fa6cf50ec40 in clone3 () from /lib64/libc.so.6
Thread 4 (Thread 0x7fa6cce3b640 (LWP 3048093) "python3.11"):
#0 0x00007fa6cf48679a in __futex_abstimed_wait_common () from /lib64/libc.so.6
#1 0x00007fa6cf4892a4 in pthread_cond_timedwait
GLIBC_2.3.2 () from /lib64/libc.so.6
#2 0x00007fa6cf9a5f1a in take_gil () from /lib64/libpython3.11.so.1.0
#3 0x00007fa6cf9beae6 in PyEval_RestoreThread () from /lib64/libpython3.11.so.1.0
#4 0x00007fa6cfa5effe in acquire_timed () from /lib64/libpython3.11.so.1.0
#5 0x00007fa6cfa5edbf in lock_PyThread_acquire_lock () from /lib64/libpython3.11.so.1.0
#6 0x00007fa6cf9deabd in method_vectorcall_VARARGS_KEYWORDS () from /lib64/libpython3.11.so.1.0
#7 0x00007fa6cf9cff1c in PyObject_Vectorcall () from /lib64/libpython3.11.so.1.0
#8 0x00007fa6cf9c0c9e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#9 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#10 0x00007fa6cf9f94f2 in method_vectorcall () from /lib64/libpython3.11.so.1.0
#11 0x00007fa6cfaa86cc in thread_run () from /lib64/libpython3.11.so.1.0
#12 0x00007fa6cfa76528 in pythread_wrapper () from /lib64/libpython3.11.so.1.0
#13 0x00007fa6cf489c02 in start_thread () from /lib64/libc.so.6
#14 0x00007fa6cf50ec40 in clone3 () from /lib64/libc.so.6
Thread 3 (Thread 0x7fa6cd63c640 (LWP 3048085) "python3.11"):
#0 0x00007fa6cf50f66e in recv () from /lib64/libc.so.6
#1 0x00007fa6cf6121d9 in sock_recv_impl () from /usr/lib64/python3.11/lib-dynload/_socket.cpython-311-x86_64-linux-gnu.so
#2 0x00007fa6cf614c17 in sock_call_ex () from /usr/lib64/python3.11/lib-dynload/_socket.cpython-311-x86_64-linux-gnu.so
#3 0x00007fa6cf614de4 in sock_call () from /usr/lib64/python3.11/lib-dynload/_socket.cpython-311-x86_64-linux-gnu.so
#4 0x00007fa6cf61740d in sock_recv () from /usr/lib64/python3.11/lib-dynload/_socket.cpython-311-x86_64-linux-gnu.so
#5 0x00007fa6cf9bcc39 in method_vectorcall_VARARGS () from /lib64/libpython3.11.so.1.0
#6 0x00007fa6cf9cff1c in PyObject_Vectorcall () from /lib64/libpython3.11.so.1.0
#7 0x00007fa6cf9c0c9e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#8 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#9 0x00007fa6cf9f94f2 in method_vectorcall () from /lib64/libpython3.11.so.1.0
#10 0x00007fa6cfaa86cc in thread_run () from /lib64/libpython3.11.so.1.0
#11 0x00007fa6cfa76528 in pythread_wrapper () from /lib64/libpython3.11.so.1.0
#12 0x00007fa6cf489c02 in start_thread () from /lib64/libc.so.6
#13 0x00007fa6cf50ec40 in clone3 () from /lib64/libc.so.6
Thread 2 (Thread 0x7fa6cde3d640 (LWP 3048084) "python3.11"):
#0 0x00007fa6cf48679a in __futex_abstimed_wait_common () from /lib64/libc.so.6
#1 0x00007fa6cf4892a4 in pthread_cond_timedwait
GLIBC_2.3.2 () from /lib64/libc.so.6
#2 0x00007fa6cf9a5f1a in take_gil () from /lib64/libpython3.11.so.1.0
#3 0x00007fa6cf9beae6 in PyEval_RestoreThread () from /lib64/libpython3.11.so.1.0
#4 0x00007fa6cfa5effe in acquire_timed () from /lib64/libpython3.11.so.1.0
#5 0x00007fa6cfa5edbf in lock_PyThread_acquire_lock () from /lib64/libpython3.11.so.1.0
#6 0x00007fa6cf9deabd in method_vectorcall_VARARGS_KEYWORDS () from /lib64/libpython3.11.so.1.0
#7 0x00007fa6cf9cff1c in PyObject_Vectorcall () from /lib64/libpython3.11.so.1.0
#8 0x00007fa6cf9c0c9e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#9 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#10 0x00007fa6cf9f94f2 in method_vectorcall () from /lib64/libpython3.11.so.1.0
#11 0x00007fa6cfaa86cc in thread_run () from /lib64/libpython3.11.so.1.0
#12 0x00007fa6cfa76528 in pythread_wrapper () from /lib64/libpython3.11.so.1.0
#13 0x00007fa6cf489c02 in start_thread () from /lib64/libc.so.6
#14 0x00007fa6cf50ec40 in clone3 () from /lib64/libc.so.6
Thread 1 (Thread 0x7fa6cfe3eb80 (LWP 3048077) "python3.11"):
#0 0x00007fa6cf4d8a3f in wait4 () from /lib64/libc.so.6
#1 0x00007fa6cf44b243 in do_system () from /lib64/libc.so.6
#2 0x00007fa6be4f824e in TUnixSystem::StackTrace() () from /afs/cern.ch/user/v/vstaryns/eos/timber_test_2/root_reinstall/lib/libCore.so
#3 0x00007fa6ce164083 in (anonymous namespace)::TExceptionHandlerImp::HandleException(int) () from /afs/cern.ch/user/v/vstaryns/eos/timber_test_2/root_reinstall/lib/libcppyy_backend.so
#4 0x00007fa6be4f57e1 in TUnixSystem::DispatchSignals(ESignals) () from /afs/cern.ch/user/v/vstaryns/eos/timber_test_2/root_reinstall/lib/libCore.so
#5 <signal handler called>
#6 0x00007fa6cf9b0054 in visit_decref () from /lib64/libpython3.11.so.1.0
#7 0x00007fa6cf9afcb5 in deduce_unreachable () from /lib64/libpython3.11.so.1.0
#8 0x00007fa6cf9af30b in gc_collect_main () from /lib64/libpython3.11.so.1.0
#9 0x00007fa6cfa445de in gc_collect_with_callback () from /lib64/libpython3.11.so.1.0
#10 0x00007fa6cf9ad119 in _PyObject_GC_NewVar () from /lib64/libpython3.11.so.1.0
#11 0x00007fa6cf9ac3dc in PyTuple_New () from /lib64/libpython3.11.so.1.0
#12 0x00007fa6cf9fddbd in _PyCode_ConstantKey () from /lib64/libpython3.11.so.1.0
#13 0x00007fa6cfa04a92 in merge_const_one () from /lib64/libpython3.11.so.1.0
#14 0x00007fa6cfa020dd in assemble () from /lib64/libpython3.11.so.1.0
#15 0x00007fa6cf9f9ee3 in compiler_visit_stmt () from /lib64/libpython3.11.so.1.0
#16 0x00007fa6cfa5e0e8 in compiler_body () from /lib64/libpython3.11.so.1.0
#17 0x00007fa6cfa5587a in _PyAST_Compile () from /lib64/libpython3.11.so.1.0
#18 0x00007fa6cfa48a1e in Py_CompileStringObject () from /lib64/libpython3.11.so.1.0
#19 0x00007fa6cfa6af30 in builtin_compile () from /lib64/libpython3.11.so.1.0
#20 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#21 0x00007fa6cf9e92b1 in _PyVectorcall_Call () from /lib64/libpython3.11.so.1.0
#22 0x00007fa6cf9c9f8d in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#23 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#24 0x00007fa6cf9d6c86 in object_vacall () from /lib64/libpython3.11.so.1.0
#25 0x00007fa6cf9f8e76 in PyObject_CallMethodObjArgs () from /lib64/libpython3.11.so.1.0
#26 0x00007fa6cf9f8a2c in PyImport_ImportModuleLevelObject () from /lib64/libpython3.11.so.1.0
#27 0x00007fa6cfa06fb2 in builtin___import__ () from /lib64/libpython3.11.so.1.0
#28 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#29 0x00007fa6cf9c9f8d in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#30 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#31 0x00007fa6cf9d6c86 in object_vacall () from /lib64/libpython3.11.so.1.0
#32 0x00007fa6cf9f8e76 in PyObject_CallMethodObjArgs () from /lib64/libpython3.11.so.1.0
#33 0x00007fa6cf9f8ab9 in PyImport_ImportModuleLevelObject () from /lib64/libpython3.11.so.1.0
#34 0x00007fa6cf9c7a4e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#35 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#36 0x00007fa6cfa49586 in PyEval_EvalCode () from /lib64/libpython3.11.so.1.0
#37 0x00007fa6cfa607e5 in builtin_exec () from /lib64/libpython3.11.so.1.0
#38 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#39 0x00007fa6cf9c9f8d in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#40 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#41 0x00007fa6cf9d6c86 in object_vacall () from /lib64/libpython3.11.so.1.0
#42 0x00007fa6cf9f8e76 in PyObject_CallMethodObjArgs () from /lib64/libpython3.11.so.1.0
#43 0x00007fa6cf9f8a2c in PyImport_ImportModuleLevelObject () from /lib64/libpython3.11.so.1.0
#44 0x00007fa6cf9c7a4e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#45 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#46 0x00007fa6cfa49586 in PyEval_EvalCode () from /lib64/libpython3.11.so.1.0
#47 0x00007fa6cfa607e5 in builtin_exec () from /lib64/libpython3.11.so.1.0
#48 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#49 0x00007fa6cf9c9f8d in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#50 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#51 0x00007fa6cf9d6c86 in object_vacall () from /lib64/libpython3.11.so.1.0
#52 0x00007fa6cf9f8e76 in PyObject_CallMethodObjArgs () from /lib64/libpython3.11.so.1.0
#53 0x00007fa6cf9f8a2c in PyImport_ImportModuleLevelObject () from /lib64/libpython3.11.so.1.0
#54 0x00007fa6cf9c7a4e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#55 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#56 0x00007fa6cfa49586 in PyEval_EvalCode () from /lib64/libpython3.11.so.1.0
#57 0x00007fa6cfa607e5 in builtin_exec () from /lib64/libpython3.11.so.1.0
#58 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#59 0x00007fa6cf9cff1c in PyObject_Vectorcall () from /lib64/libpython3.11.so.1.0
#60 0x00007fa6cf9ccb7c in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#61 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#62 0x00007fa6cfa49586 in PyEval_EvalCode () from /lib64/libpython3.11.so.1.0
#63 0x00007fa6cfa607e5 in builtin_exec () from /lib64/libpython3.11.so.1.0
#64 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#65 0x00007fa6cf9cff1c in PyObject_Vectorcall () from /lib64/libpython3.11.so.1.0
#66 0x00007fa6cf9c0c9e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#67 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#68 0x00007fa6cfa732d9 in pymain_run_module () from /lib64/libpython3.11.so.1.0
#69 0x00007fa6cf9250f2 in Py_RunMain.cold () from /lib64/libpython3.11.so.1.0
#70 0x00007fa6cfa38fad in Py_BytesMain () from /lib64/libpython3.11.so.1.0
#71 0x00007fa6cf429590 in __libc_start_call_main () from /lib64/libc.so.6
#72 0x00007fa6cf429640 in __libc_start_main_impl () from /lib64/libc.so.6
#73 0x000055d2a91b5095 in _start ()
===========================================================
The lines below might hint at the cause of the crash. If you see question
marks as part of the stack trace, try to recompile with debugging information
enabled and export CLING_DEBUG=1 environment variable before running.
You may get help by asking at the ROOT forum https://root.cern/forum
preferably using the command (.forum bug) in the ROOT prompt.
Only if you are really convinced it is a bug in ROOT then please submit a
report at https://root.cern/bugs or (preferably) using the command (.gh bug) in
the ROOT prompt. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#6 0x00007fa6cf9b0054 in visit_decref () from /lib64/libpython3.11.so.1.0
#7 0x00007fa6cf9afcb5 in deduce_unreachable () from /lib64/libpython3.11.so.1.0
#8 0x00007fa6cf9af30b in gc_collect_main () from /lib64/libpython3.11.so.1.0
#9 0x00007fa6cfa445de in gc_collect_with_callback () from /lib64/libpython3.11.so.1.0
#10 0x00007fa6cf9ad119 in _PyObject_GC_NewVar () from /lib64/libpython3.11.so.1.0
#11 0x00007fa6cf9ac3dc in PyTuple_New () from /lib64/libpython3.11.so.1.0
#12 0x00007fa6cf9fddbd in _PyCode_ConstantKey () from /lib64/libpython3.11.so.1.0
#13 0x00007fa6cfa04a92 in merge_const_one () from /lib64/libpython3.11.so.1.0
#14 0x00007fa6cfa020dd in assemble () from /lib64/libpython3.11.so.1.0
#15 0x00007fa6cf9f9ee3 in compiler_visit_stmt () from /lib64/libpython3.11.so.1.0
#16 0x00007fa6cfa5e0e8 in compiler_body () from /lib64/libpython3.11.so.1.0
#17 0x00007fa6cfa5587a in _PyAST_Compile () from /lib64/libpython3.11.so.1.0
#18 0x00007fa6cfa48a1e in Py_CompileStringObject () from /lib64/libpython3.11.so.1.0
#19 0x00007fa6cfa6af30 in builtin_compile () from /lib64/libpython3.11.so.1.0
#20 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#21 0x00007fa6cf9e92b1 in _PyVectorcall_Call () from /lib64/libpython3.11.so.1.0
#22 0x00007fa6cf9c9f8d in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#23 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#24 0x00007fa6cf9d6c86 in object_vacall () from /lib64/libpython3.11.so.1.0
#25 0x00007fa6cf9f8e76 in PyObject_CallMethodObjArgs () from /lib64/libpython3.11.so.1.0
#26 0x00007fa6cf9f8a2c in PyImport_ImportModuleLevelObject () from /lib64/libpython3.11.so.1.0
#27 0x00007fa6cfa06fb2 in builtin___import__ () from /lib64/libpython3.11.so.1.0
#28 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#29 0x00007fa6cf9c9f8d in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#30 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#31 0x00007fa6cf9d6c86 in object_vacall () from /lib64/libpython3.11.so.1.0
#32 0x00007fa6cf9f8e76 in PyObject_CallMethodObjArgs () from /lib64/libpython3.11.so.1.0
#33 0x00007fa6cf9f8ab9 in PyImport_ImportModuleLevelObject () from /lib64/libpython3.11.so.1.0
#34 0x00007fa6cf9c7a4e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#35 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#36 0x00007fa6cfa49586 in PyEval_EvalCode () from /lib64/libpython3.11.so.1.0
#37 0x00007fa6cfa607e5 in builtin_exec () from /lib64/libpython3.11.so.1.0
#38 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#39 0x00007fa6cf9c9f8d in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#40 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#41 0x00007fa6cf9d6c86 in object_vacall () from /lib64/libpython3.11.so.1.0
#42 0x00007fa6cf9f8e76 in PyObject_CallMethodObjArgs () from /lib64/libpython3.11.so.1.0
#43 0x00007fa6cf9f8a2c in PyImport_ImportModuleLevelObject () from /lib64/libpython3.11.so.1.0
#44 0x00007fa6cf9c7a4e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#45 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#46 0x00007fa6cfa49586 in PyEval_EvalCode () from /lib64/libpython3.11.so.1.0
#47 0x00007fa6cfa607e5 in builtin_exec () from /lib64/libpython3.11.so.1.0
#48 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#49 0x00007fa6cf9c9f8d in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#50 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#51 0x00007fa6cf9d6c86 in object_vacall () from /lib64/libpython3.11.so.1.0
#52 0x00007fa6cf9f8e76 in PyObject_CallMethodObjArgs () from /lib64/libpython3.11.so.1.0
#53 0x00007fa6cf9f8a2c in PyImport_ImportModuleLevelObject () from /lib64/libpython3.11.so.1.0
#54 0x00007fa6cf9c7a4e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#55 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#56 0x00007fa6cfa49586 in PyEval_EvalCode () from /lib64/libpython3.11.so.1.0
#57 0x00007fa6cfa607e5 in builtin_exec () from /lib64/libpython3.11.so.1.0
#58 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#59 0x00007fa6cf9cff1c in PyObject_Vectorcall () from /lib64/libpython3.11.so.1.0
#60 0x00007fa6cf9ccb7c in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#61 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#62 0x00007fa6cfa49586 in PyEval_EvalCode () from /lib64/libpython3.11.so.1.0
#63 0x00007fa6cfa607e5 in builtin_exec () from /lib64/libpython3.11.so.1.0
#64 0x00007fa6cf9cffba in cfunction_vectorcall_FASTCALL_KEYWORDS () from /lib64/libpython3.11.so.1.0
#65 0x00007fa6cf9cff1c in PyObject_Vectorcall () from /lib64/libpython3.11.so.1.0
#66 0x00007fa6cf9c0c9e in _PyEval_EvalFrameDefault () from /lib64/libpython3.11.so.1.0
#67 0x00007fa6cf9bce12 in _PyEval_Vector () from /lib64/libpython3.11.so.1.0
#68 0x00007fa6cfa732d9 in pymain_run_module () from /lib64/libpython3.11.so.1.0
#69 0x00007fa6cf9250f2 in Py_RunMain.cold () from /lib64/libpython3.11.so.1.0
#70 0x00007fa6cfa38fad in Py_BytesMain () from /lib64/libpython3.11.so.1.0
#71 0x00007fa6cf429590 in __libc_start_call_main () from /lib64/libc.so.6
#72 0x00007fa6cf429640 in __libc_start_main_impl () from /lib64/libc.so.6
#73 0x000055d2a91b5095 in _start ()
===========================================================
However when I rearange the program so that the imports (other than import ROOT) are below ROOT.TMVA.PyMethodBase.PyInitialize(), the programs runs properly, and ends without error.
Thank you for the detauled information. It is good we have a workaround. I see you are using library of python3.11, not 3.9. Maybethe mixing of the Python versions causes this issue.
Is the problem happening also if you do:
import ROOT
import numpy as np
ROOT.TMVA.PyMethodBase.PyInitialize()
import ROOT
import numpy as np
ROOT.TMVA.PyMethodBase.PyInitialize()
but not if i do
import ROOT
ROOT.TMVA.PyMethodBase.PyInitialize()
import numpy as np
print("success")
The python version is a good catch. When I run python --version the output is Python 3.9.18, when I run root-config --python-version the output is 3.9.18, and when i run root-config --python3-version the output is 3.9.18. I am not sure what else to check to see where python 3.11 is being referenced.
If ROOT has been built with the Python version 3.9 and the python library from version 3.11 are loaded, this is very likely to cause this crash. Maybe the LD_LIBRARY_PATH is not correctly set.