The labelVolume
segmentation fault and general strange behaviour of the labelVolume*
functions is due to an over-optimization by gcc-4.8.1 with -O3
.
Solution set the flag to -O2
.
With the recent libboost, I'm having segmentation faults in labelVolumeWithBackground() when I provide certain input volumes with a specific combination of axistags and ordering. Strangely, labelVolume() is not affected.
#!/usr/bin/python2
import vigra
import numpy as np
print("Testing for segfaults")
X = vigra.VigraArray(np.zeros((3,20,50)), axistags=vigra.defaultAxistags('zyx'))
labels = vigra.analysis.labelVolumeWithBackground(X)
print("np.zeros worked")
X = vigra.VigraArray(np.ones((3,20,50), dtype=np.uint8), axistags=vigra.defaultAxistags('xyz'))
labels = vigra.analysis.labelVolumeWithBackground(X)
print("XYZ (order=C) worked.")
X = vigra.VigraArray(np.ones((3,20,50), dtype=np.uint8), order='F', axistags=vigra.defaultAxistags('zyx'))
labels = vigra.analysis.labelVolumeWithBackground(X)
print("ZYX (order=F) worked.")
X = vigra.VigraArray(np.ones((3,20,50), dtype=np.uint8), order='C', axistags=vigra.defaultAxistags('zyx'))
labels = vigra.analysis.labelVolume(X)
print("ZYX (order=C, labelVolume() )worked.")
# this example fails with segmentation fault
# Linux burger-Desktop 3.9.9-1-ARCH #1 SMP PREEMPT Wed Jul 3 22:45:16 CEST 2013 x86_64 GNU/Linux
# LIBS:
# python2 2.7.5-1
# boost-libs 1.54.0-2
X = vigra.VigraArray(np.ones((3,20,50), dtype=np.uint8), order='C', axistags=vigra.defaultAxistags('zyx'))
labels = vigra.analysis.labelVolumeWithBackground(X)
print("You fixed it.")
Output:
Testing for segfaults
np.zeros worked
XYZ (order=C) worked.
ZYX (order=F) worked.
ZYX (order=C, labelVolume() )worked.
Segmentation fault (core dumped)
Backtrace:
#0 0x00007fffef7e5115 in unsigned int vigra::labelVolumeWithBackground<vigra::StridedMultiIterator<3u, float, float const&, float const*>, vigra::StandardConstValueAccessor<float>, vigra::TinyVector<long, 3>, vigra::StridedMultiIterator<3u, unsigned int, unsigned int&, unsigned int*>, vigra::StandardValueAccessor<unsigned int>, vigra::Neighborhood3DSix::NeighborCode3D, float, std::equal_to<float> >(vigra::StridedMultiIterator<3u, float, float const&, float const*>, vigra::TinyVector<long, 3>, vigra::StandardConstValueAccessor<float>, vigra::StridedMultiIterator<3u, unsigned int, unsigned int&, unsigned int*>, vigra::StandardValueAccessor<unsigned int>, vigra::Neighborhood3DSix::NeighborCode3D, float, std::equal_to<float>) () from /usr/lib/python2.7/site-packages/vigra/analysis.so
#1 0x00007fffef7efee5 in vigra::NumpyAnyArray vigra::pythonLabelVolumeWithBackground<float>(vigra::NumpyArray<3u, vigra::Singleband<float>, vigra::StridedArrayTag>, int, float, vigra::NumpyArray<3u, vigra::Singleband<unsigned int>, vigra::StridedArrayTag>) () from /usr/lib/python2.7/site-packages/vigra/analysis.so
#2 0x00007fffef851c40 in boost::python::detail::caller_arity<4u>::impl<vigra::NumpyAnyArray (*)(vigra::NumpyArray<3u, vigra::Singleband<float>, vigra::StridedArrayTag>, int, float, vigra::NumpyArray<3u, vigra::Singleband<unsigned int>, vigra::StridedArrayTag>), boost::python::default_call_policies, boost::mpl::vector5<vigra::NumpyAnyArray, vigra::NumpyArray<3u, vigra::Singleband<float>, vigra::StridedArrayTag>, int, float, vigra::NumpyArray<3u, vigra::Singleband<unsigned int>, vigra::StridedArrayTag> > >::operator()(_object*, _object*) () from /usr/lib/python2.7/site-packages/vigra/analysis.so
#3 0x00007ffff656444a in boost::python::objects::function::call(_object*, _object*) const () from /usr/lib/libboost_python.so.1.54.0
#4 0x00007ffff65647b8 in ?? () from /usr/lib/libboost_python.so.1.54.0
#5 0x00007ffff656e4e3 in boost::python::handle_exception_impl(boost::function0<void>) () from /usr/lib/libboost_python.so.1.54.0
#6 0x00007ffff6562f73 in ?? () from /usr/lib/libboost_python.so.1.54.0
#7 0x00007ffff7a63c13 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#8 0x00007ffff7af39e1 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#9 0x00007ffff7af8290 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#10 0x00007ffff7af8392 in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1.0
#11 0x00007ffff7b1108f in run_mod () from /usr/lib/libpython2.7.so.1.0
#12 0x00007ffff7b121ae in PyRun_FileExFlags () from /usr/lib/libpython2.7.so.1.0
#13 0x00007ffff7b13319 in PyRun_SimpleFileExFlags () from /usr/lib/libpython2.7.so.1.0
#14 0x00007ffff7b23c1f in Py_Main () from /usr/lib/libpython2.7.so.1.0
#15 0x00007ffff7472a15 in __libc_start_main () from /usr/lib/libc.so.6
#16 0x0000000000400741 in _start ()