[vtkusers] vtkpython:Linux SMP:SIGSEGV upon import vtk

Brent Goodrick bgoodrick at ipns.com
Thu Feb 27 11:43:34 EST 2003


Prabhu>  1. Was VTK built on this same machine or was it built elsewhere and
Prabhu>  used on this machine?

Prabhu>  2. I used to believe that the gcc, glibc and all should kind of be in
Prabhu>  sync.  So could this be because you are using gcc-3.04 on RH 6.1 with
Prabhu>  its older glibc compiled on an older gcc version?  Could there be a
Prabhu>  problem with the linker?  I don't know enough about this to say
Prabhu>  anything definitive but maybe something worth thinking about?
Prabhu>  Perhaps you can try building it with the default RH 6.1 compiler?  Or
Prabhu>  better still upgrade the machine.

That concerned me too (I'm on Red Hat 7.3 however and even building
VTK on GCC 3.2.1), so I double checked that if I moved the VTK/bin
somewhere, that the runtime linker could still find the shared libraries
therein, provided LD_LIBRARY_PATH was set properly:

  cd /tmp/VTK/bin
  cd ..
  mv bin bin2
  
  # now change the LD_LIBRARY_PATH that ldd will lookup things in the
  # bin2 directory:
  LD_LIBRARY_PATH=`pwd`/bin2:$LD_LIBRARY_PATH
  export LD_LIBRARY_PATH
  
  ldd bin2/libvtkCommonPython.so
  
  # ok now move it back as it was:
  mv bin2 bin


ldd then spits out the fact that it found its dependency libraries in
the bin2 directory:

	libvtkCommon.so => /tmp/VTK/VTK/bin2/libvtkCommon.so (0x402c6000)
	libpthread.so.0 => /lib/i686/libpthread.so.0 (0x404f2000)
	libdl.so.2 => /lib/libdl.so.2 (0x40506000)
	libstdc++.so.5 => not found
	libm.so.6 => /lib/i686/libm.so.6 (0x40509000)
	libgcc_s.so.1 => not found
	libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
	libstdc++.so.5 => not found
	libgcc_s.so.1 => not found

If I did not add the bin2 directory, it would not find it.  If I did
not move the bin directory to the bin2 directory and did not change
the LD_LIBRARY_PATH, then it _would_ still find it because there must
be a default path set inside the .so that is hardcoded to your build
directory. 

Notice above also that the libstdc++.so.5 was not found!  Why? because
LD_LIBRARY_PATH does not include my special path to the GCC 3.2.1
libstdc++.so* libraries.  My Red Hat 7.3 box comes installed with gcc
2.96 and installs its libraries in /usr/lib along with some
compatibility libraries, but I compiled VTK with GCC 3.2.1.  Ok,
that's good for me but bad for you because if you compiled your
binaries on a Red Hat 6.1 machine using /usr/bin/gcc but execute on a
Red Hat 7.x machine, the linker may succeed in finding the same named,
but incompatible, libstdc++.so* fileset, try to link with it, and
sigsegv on you, leaving you puzzled.

Try using the following script, modifying the following script for
your own use, being very careful to match up the proper directories to
GCC_HEAD, VTK_HEAD (my non-standard variable names), and PYTHONHOME.
This script probably does the same thing that the vtkpython executable
is doing, but in a way that allows you to skirt the hardcoded paths
inside vtkpython.  See if it works; if you still get a sigsegv, then
try recompiling and executing all on your Red Hat 7.x box using the
_same_ compiler and libraries in both compilation and execution, and
try using the resulting vtkpython.

--------------------------------------------------------------------------------
--- run_vtk_python.sh ---
--------------------------------------------------------------------------------
#!/bin/sh


# runs vtk python scripts in current directory without using vtkpython
# 
# USAGE: $0 executable arg arg arg...
# 
# Where executable is something like the Cone.py script underneath the
# VTK examples directory.
# 
# This just sets the *PATH* environment variables appropriately and runs
# the Python script.



# setup path to top directory of VTK builds. Should eventually be an
# argument to this script:
VTK_HEAD=/scratch1/overflow/brentg/raw/VTK/VTK

# setup path to the version of gcc I want (obviously must match one
# used to compile vtk). should eventually be an argument to this script:
GCC_HEAD=/scratch1/gcc-3.2.1/Linux_2_4_18_3

# setup path to the version of python I want:
PYTHONHOME=/scratch1/overflow/Python-2.2.1; export PYTHONHOME


PATH="$PYTHONHOME/bin:$PATH"; export PATH
PYTHONPATH=${VTK_HEAD}/Wrapping/Python:${VTK_HEAD}/bin:$PYTHONPATH; export PYTHONPATH

LD_LIBRARY_PATH=${VTK_HEAD}/lib:${GCC_HEAD}/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH

# "python", is just the plain python version 2.2.1:
echo; echo Now executing "python $@"
python "$@"


--------------------------------------------------------------------------------

Good Luck,
Brent Goodrick





More information about the vtkusers mailing list