Slicer crash on fresh build

Hi, I am trying to get Slicer to build and run on my home computer.
It is debian testing with gcc 6 (unfortunately gcc 5 no longer offered).
Clean directory, disable SimpleITK, disable BRAINS,
ignore inevitible BRAINSCommon build failures. Slicer builds.
Got the following error when trying to run. Any ideas?
Thanks,
Greg

$ ./Slicer-build/Slicer
Traceback (most recent call last):
  File "<string>", line 7, in <module>
  File "/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/bin/Python/slicer/slicerqt.py", line 6, in <module>
    import vtk
  File "/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/Wrapping/Python/vtk/__init__.py", line 41, in <module>
    from .vtkCommonKit import *
  File "/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/Wrapping/Python/vtk/vtkCommonKit.py", line 9, in <module>
    from vtkCommonKitPython import *
ImportError: /home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/./libvtkCommonKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8
Traceback (most recent call last):
  File "<string>", line 7, in <module>
  File "/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/bin/Python/slicer/slicerqt-with-tcl.py", line 42, in <module>
    slicer.sliceWidgets = {}
NameError: name 'slicer' is not defined
/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/./libvtkRenderingKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8
/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/./libvtkRenderingKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8
/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/./libvtkRenderingKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8
/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/./libvtkRenderingKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'getSlicerRCFileName' is not defined
Number of registered modules: 85 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/lib/Slicer-4.7/qt-scripted-modules/CompareVolumes.py", line 3, in <module>
    from __main__ import vtk, qt, ctk, slicer
ImportError: cannot import name vtk
loadSourceAsModule - Failed to load file "/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/lib/Slicer-4.7/qt-scripted-modules/CompareVolumes.py"  as module "CompareVolumes" ! 
Fail to instantiate module  "CompareVolumes" 
error: [/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/bin/./SlicerApp-real] exit abnormally - Report the problem.
gsharp@wormwood:~/build/slicer-4/Slicer-build$ rm -rf ~/.config/NA-MIC/
gsharp@wormwood:~/build/slicer-4/Slicer-build$ ./Slicer-build/Slicer
Traceback (most recent call last):
  File "<string>", line 7, in <module>
  File "/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/bin/Python/slicer/slicerqt.py", line 6, in <module>
    import vtk
  File "/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/Wrapping/Python/vtk/__init__.py", line 41, in <module>
    from .vtkCommonKit import *
  File "/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/Wrapping/Python/vtk/vtkCommonKit.py", line 9, in <module>
    from vtkCommonKitPython import *
ImportError: /home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/./libvtkCommonKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8
Traceback (most recent call last):
  File "<string>", line 7, in <module>
  File "/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/bin/Python/slicer/slicerqt-with-tcl.py", line 42, in <module>
    slicer.sliceWidgets = {}
NameError: name 'slicer' is not defined
/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/./libvtkRenderingKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8
/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/./libvtkRenderingKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8
/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/./libvtkRenderingKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8
/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/./libvtkRenderingKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'getSlicerRCFileName' is not defined
Number of registered modules: 85 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/lib/Slicer-4.7/qt-scripted-modules/CompareVolumes.py", line 3, in <module>
    from __main__ import vtk, qt, ctk, slicer
ImportError: cannot import name vtk
loadSourceAsModule - Failed to load file "/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/lib/Slicer-4.7/qt-scripted-modules/CompareVolumes.py"  as module "CompareVolumes" ! 
Fail to instantiate module  "CompareVolumes" 
error: [/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/bin/./SlicerApp-real] exit abnormally - Report the problem.

Do you have the error if you don’t disable BRAINS?

Looks like a mix of python versions. Maybe check that your environment doesn’t have and LD_PRELOAD. Also double check that the Slicer-build/Slicer --launcher-dump-environment looks like it has all the correct paths.

Do you have the error if you don’t disable BRAINS?

BRAINS doesn’t build.

http://na-mic.org/Mantis/view.php?id=4268

Looks like a mix of python versions. Maybe check that your
environment doesn’t have and LD_PRELOAD. Also double check that the
Slicer-build/Slicer --launcher-dump-environment looks like it has all
the correct paths.

LD_PRELOAD is not set.

The environment looks fine to me. However, I don’t really know what I
am looking for. Pasted below.

LD_LIBRARY_PATH=/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/bin/.:/usr/lib/x86_64-linux-gnu:../lib/Slicer-4.7/qt-loadable-modules:/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/lib/Slicer-4.7/cli-modules/.:/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/lib/Slicer-4.7/qt-loadable-modules/.:/home/gsharp/build/slicer-4/Slicer-build/OpenSSL:/home/gsharp/build/slicer-4/Slicer-build/tcl-build/lib:/home/gsharp/build/slicer-4/Slicer-build/python-install/lib:/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/.:/home/gsharp/build/slicer-4/Slicer-build/teem-build/bin/.:/home/gsharp/build/slicer-4/Slicer-build/DCMTK-build/lib/.:/home/gsharp/build/slicer-4/Slicer-build/ITKv4-build/lib/.:/home/gsharp/build/slicer-4/Slicer-build/CTK-build/CTK-build/bin/.:/home/gsharp/build/slicer-4/Slicer-build/CTK-build/QtTesting-build/.:/home/gsharp/build/slicer-4/Slicer-build/CTK-build/PythonQt-build/.:/home/gsharp/build/slicer-4/Slicer-build/LibArchive-install/lib:/home/gsharp/build/slicer-4/Slicer-build/OpenIGTLink-build:/home/gsharp/build/slicer-4/Slicer-build/OpenIGTLink-build/bin/.:/home/gsharp/build/slicer-4/Slicer-build/JsonCpp-build/src/lib_json/.:/home/gsharp/build/slicer-4/Slicer-build/ParameterSerializer-build/lib/.:/home/gsharp/build/slicer-4/Slicer-build/SlicerExecutionModel-build/ModuleDescriptionParser/bin/.:/home/gsharp/build/slicer-4/Slicer-build/python-install/lib/python2.7/site-packages/numpy/core:/home/gsharp/build/slicer-4/Slicer-build/python-install/lib/python2.7/site-packages/numpy/lib
PATH=/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/bin/.:/usr/lib/x86_64-linux-gnu/qt4/bin:/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/lib/Slicer-4.7/cli-modules/.:/home/gsharp/build/slicer-4/Slicer-build/tcl-build/bin:/home/gsharp/build/slicer-4/Slicer-build/python-install/bin:/home/gsharp/build/slicer-4/Slicer-build/teem-build/bin/.
PYTHONHOME=/home/gsharp/build/slicer-4/Slicer-build/python-install
PYTHONNOUSERSITE=1
PYTHONPATH=/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/bin/.:/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/bin/Python:/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/lib/Slicer-4.7/qt-loadable-modules/.:/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/lib/Slicer-4.7/qt-loadable-modules/Python:/home/gsharp/build/slicer-4/Slicer-build/python-install/lib/python2.7/lib-tk:/home/gsharp/build/slicer-4/Slicer-build/python-install/lib/python2.7:/home/gsharp/build/slicer-4/Slicer-build/python-install/lib/python2.7/lib-dynload:/home/gsharp/build/slicer-4/Slicer-build/python-install/lib/python2.7/site-packages:/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/Wrapping/Python:/home/gsharp/build/slicer-4/Slicer-build/VTKv7-build/lib/.:/home/gsharp/build/slicer-4/Slicer-build/CTK-build/CTK-build/bin/Python:/home/gsharp/build/slicer-4/Slicer-build/CTK-build/CTK-build/bin/.
QT_PLUGIN_PATH=/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/bin:/home/gsharp/build/slicer-4/Slicer-build/CTK-build/CTK-build/bin:/usr/lib/x86_64-linux-gnu/qt4/plugins
SLICER_HOME=/home/gsharp/build/slicer-4/Slicer-build/Slicer-build
SSL_CERT_FILE=/home/gsharp/build/slicer-4/Slicer-build/Slicer-build/share/Slicer-4.7/Slicer.crt
TCLLIBPATH=/home/gsharp/build/slicer-4/Slicer-build/tcl-build/lib/itcl4.0.1
TCL_LIBRARY=/home/gsharp/build/slicer-4/Slicer-build/tcl-build/lib/tcl8.6
TK_LIBRARY=/home/gsharp/build/slicer-4/Slicer-build/tcl-build/lib/tk8.6

Interesting - in LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu is inserted before the slicer build directories. That looks wrong to me since that directory has other python shared libraries that aren’t the ones slicer builds.

Maybe if you start a new terminal (with Slicer --xterm) you can set the LD_LIBRARY_PATH without that entry (or move it to the end if needed to resolve other libs). You can run Slicer-build/bin/SlicerApp-real and see if it works.

I can confirm that on my ubuntu I have the same /usr/lib/x86_64 entry in LD_LIBRARY_PATH, but I don’t get a crash but I probably have a different python version.

Interesting - in LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu is
inserted before the slicer build directories. That looks wrong to me
since that directory has other python shared libraries that aren’t
the ones slicer builds.

Maybe if you start a new terminal (with Slicer --xterm) you can set
the LD_LIBRARY_PATH without that entry (or move it to the end if
needed to resolve other libs). You can run
Slicer-build/bin/SlicerApp-real and see if it works.

I can confirm that on my ubuntu I have the same /usr/lib/x86_64 entry
in LD_LIBRARY_PATH, but I don’t get a crash but I probably have a
different python version.

Sadly, the result is “Segmentation fault”.

For the record:

$ which python
/usr/bin/python
$ python --version
Python 2.7.13

I will rebuild in debug mode, and get a stack trace.
Any other ideas helpful.

Thanks!
Greg

This is a known limitation of our build system, see http://www.na-mic.org/Bug/view.php?id=3574

In a nutshell, if Qt is installer in a system location, configure with -DSlicer_USE_SYSTEM_QT:BOOL=1

I will look at this after https://github.com/Slicer/Slicer/pull/727 is integrated.