Segmentation Fault (core dumped) python3


_ROOT Version:root-6.16.00
_Platform: Windows Subsystem for Linux(Ubuntu 18.04 LTE)
Compiler: cmake (3.10.2)


Hello everyone,
I’m a beginner of ROOT and all computing analysis.
I’ve already compiled ROOT with cmake and I would like to use pyROOT from python3.
So I Then, I got an error message below.

$ pyhton3
Python 3.6.7 (default, Oct22 2018, 11:32:17)
[GCC 8.2.0] on linux

import ROOT
[1] 10220 segmentation fault (core dumped) python3
$

I already searched the web and Stack Overflow but I couldn’t find any answer.
I have no idea to solve this error.
What does " segmentation fault " mean?

Any help will be appreciated.

Makoto

Dear Makoto,

Please make sure you follow the instructions to build ROOT at this link:
https://root.cern.ch/building-root

In particular, it is important to make sure you built ROOT with the Python3 installation you want to use. The following properties:

Python PYTHON_EXECUTABLE PATH Python interpreter executable
PYTHON_INCLUDE_DIR PATH Directory where to find Python.h
PYTHON_LIBRARY PATH Full path to Python library

should point to the right Python installation. You can check if that is the case by inspecting CMakeCache.txt in your build directory and looking for the value of those properties.

Dear etejedor,
thank you for your quick reply and then I checked CMakeCache.txt.
Here’s my CMakeCache.txt ( PYTHON_INCLUDE_DIR & PYTHON_LIBRARY).

PYTHON3:UNINITIALIZED=ON

PYTHON3-CACHED:STRING=ON

//Path to a program.
PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3

PYTHON_EXECUTABLE-CACHED:STRING=/usr/bin/python3

//Path to a file.
PYTHON_INCLUDE_DIR:PATH=/usr/include/python3.6m

//Path to a library.
PYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.6m.so

I cannot figure out what is wrong.
The PYTHON_INCLUDE_DIR points /usr/include/python3.6m and it has Python.h.

Regards,
Makoto

Hi, all,
Just to add another data point here, I am having what seems to be the same issue. I’ve checked my CMakeCache.txt, and the environment variables are pointing to the correct places (as far as I can tell).
I’m on Mac OSX, running Anaconda python3.7. I’ve tried a fresh build of ROOT (6.16.00). cmake seems to get all of the environment variables correct on its own.

The error is manifesting as

mmcc @ ~> python
Python 3.7.3 (default, Mar 27 2019, 16:54:48)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TVector3

 *** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[/anaconda3/lib/libpython3.7m.dylib] PyUnicode_InternFromString (no debug info)
[/usr/local/root_build//lib//libPyROOT.so] PyROOT::CreatePyStrings() /usr/local/root-6.16.00/bindings/pyroot/src/PyStrings.cxx:64
[/usr/local/root_build//lib//libPyROOT.so] PyInit_libPyROOT /usr/local/root-6.16.00/bindings/pyroot/src/RootModule.cxx:848
[/anaconda3/bin//python] _PyImport_LoadDynamicModuleWithSpec (no debug info)
[/anaconda3/bin//python] _imp_create_dynamic (no debug info)
[/anaconda3/bin//python] _PyMethodDef_RawFastCallDict (no debug info)
[/anaconda3/bin//python] PyCFunction_Call (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] _PyEval_EvalCodeWithName (no debug info)
[/anaconda3/bin//python] _PyFunction_FastCallKeywords (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] object_vacall (no debug info)
[/anaconda3/bin//python] _PyObject_CallMethodIdObjArgs (no debug info)
[/anaconda3/bin//python] PyImport_ImportModuleLevelObject (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] _PyEval_EvalCodeWithName (no debug info)
[/anaconda3/bin//python] builtin_exec (no debug info)
[/anaconda3/bin//python] _PyMethodDef_RawFastCallDict (no debug info)
[/anaconda3/bin//python] PyCFunction_Call (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] _PyEval_EvalCodeWithName (no debug info)
[/anaconda3/bin//python] _PyFunction_FastCallKeywords (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] object_vacall (no debug info)
[/anaconda3/bin//python] _PyObject_CallMethodIdObjArgs (no debug info)
[/anaconda3/bin//python] PyImport_ImportModuleLevelObject (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] _PyEval_EvalCodeWithName (no debug info)
[/anaconda3/bin//python] builtin_exec (no debug info)
[/anaconda3/bin//python] _PyMethodDef_RawFastCallDict (no debug info)
[/anaconda3/bin//python] PyCFunction_Call (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] _PyEval_EvalCodeWithName (no debug info)
[/anaconda3/bin//python] _PyFunction_FastCallKeywords (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] call_function (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] function_code_fastcall (no debug info)
[/anaconda3/bin//python] object_vacall (no debug info)
[/anaconda3/bin//python] _PyObject_CallMethodIdObjArgs (no debug info)
[/anaconda3/bin//python] PyImport_ImportModuleLevelObject (no debug info)
[/anaconda3/bin//python] _PyEval_EvalFrameDefault (no debug info)
[/anaconda3/bin//python] _PyEval_EvalCodeWithName (no debug info)
[/anaconda3/bin//python] PyRun_InteractiveOneObjectEx (no debug info)
[/anaconda3/bin//python] PyRun_InteractiveLoopFlags (no debug info)
[/anaconda3/bin//python] PyRun_AnyFileExFlags (no debug info)
[/anaconda3/bin//python] pymain_main (no debug info)
[/anaconda3/bin//python] main (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)
[<unknown binary>] (no debug info)
mmcc @ ~>

Here is the relevant content of CMakeCache.txt, if it’s useful:

//Path to a program.
PYTHON_EXECUTABLE:FILEPATH=/anaconda3/bin/python

//Path to a file.
PYTHON_INCLUDE_DIR:PATH=/anaconda3/include/python3.7m

//Path to a library.
PYTHON_LIBRARY:FILEPATH=/anaconda3/lib/libpython3.7m.dylib

//Path to a library.
PYTHON_LIBRARY_DEBUG:FILEPATH=PYTHON_LIBRARY_DEBUG-NOTFOUND

/usr/local/root_build/lib is in my PYTHONPATH, as well.

Thanks for any help.
-mike

More info: Last night I installed a new Xcode (10.2.1), reinstalled Anaconda python (3.7), and rebuilt ROOT (6.16.00), and am having the same segmentation fault.

I installed anaconda3 in a different location, and the cmake configuration picked it up correctly.

-m

Hi, mmccracken
How did you reinstalled Anaconda python?

From Source code or brew install command?

Regards,
Makoto

Hi, Makoto,

I installed with the .pkg graphical installer.

Last night I tried to roll back to ROOT 6.14.06, but the same segmentation fault occurs.

-mike

The CMakeCache.txt seems correct for what respects Python, did you build this in Ubuntu?

@amadio any other comment?

Building ROOT and using Anaconda is a tricky combination. The compiler that you use to build ROOT should be the same compiler that Anaconda comes with.

In case you are interested, there is now a distribution of ROOT with Conda, which you can install with:
conda create --name my-root-env --channel conda-forge python=3 root

1 Like

Could you please paste here the output of otool -L path/to/libPyROOT.so? and the same for the python you use (i.e. otool -L $(which python)). That will help in debugging the problem.

Hi, Amadio. See below:

mmcc @ ~>
mmcc @ ~> otool -L /usr/local/root_build/lib//libPyROOT.so
/usr/local/root_build/lib//libPyROOT.so:
	@rpath/libPyROOT.so (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libpython3.6m.dylib (compatibility version 3.6.0, current version 3.6.0)
	@rpath/libTree.so (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libRIO.so (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libCore.so (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
mmcc @ ~>
mmcc @ ~> otool -L /anaconda3/bin/python
/anaconda3/bin/python:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
mmcc @ ~>

Looks like both refer to the same libSystem.B.dylib, but current versions are different. Strange since I installed both in the last few hours… or maybe (probably) I’m misunderstanding otool’s output.

Thanks for your help!

-m

Yes, the odd thing is that I had it working as recently as March (I think). I updated my Anaconda when I upgraded to TensorFlow 2.0, and that seems to have broken pyroot.

Since yesterday, I’ve tried several combinations of ROOT 6.16 and 6.14 with python3.6 and python3.7, with the same segmentation fault, so all signs are pointing to me having done something wrong during the install process. If I can’t locate the problem, I’ll give the Conda ROOT a try.

Thanks!

Etejedor, after a few more attempts to fix the ROOT install, I broke down and installed via conda. Thanks for the tip. Everything is working well.

-mike

Yes, I build ROOT in Ubuntu 18.04 (WSL).

I tried ldd cmmand instead of otool and terminal showed below.

"
ldd $(which python)
linux-vdso.so.1 (0x00007fffe4ed3000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcd02eb0000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fcd02c90000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fcd02a80000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fcd02870000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fcd02650000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcd022b0000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcd03a00000)
"

Excuse me, I have typed the wrong command.

ldd $(which python3) /usr/local/ROOT/root-6.16.00/cmake-build/lib
/usr/bin/python3:
linux-vdso.so.1 (0x00007ffff2e8f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff32bfb0000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff32bd90000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff32bb80000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007ff32b970000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007ff32b730000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff32b510000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff32b160000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff32c400000)
/usr/local/ROOT/root-6.16.00/cmake-build/lib:
ldd: /usr/local/ROOT/root-6.16.00/cmake-build/lib: not regular file

My terminal showed this and I assume I need to rebuild ROOT.
However, what should I do?
Do I have to clear build directory and then rebuild it?