sitkUtils.PullVolumeFromSlicer makes Slicer crash

Has anyone else compiled Slicer with SimpleITK on OSX? Does it have this same casting problem?

And your build does not exhibit this issue. Could you delete all the SITK build stuff and try with Slicer_USE_SimpleITK_SHARED:BOOL=OFF?

I wonder if anyone else has a local build of Slicer with SimpleITK enabled on OSX to check if they have this same issue?

I am actually not sure how to reproduce the factory setup (wiki info is out of date). @jcfr !!

I can set up up debug build on the factory. Steve, you posted earlier that your local (debug) build wasnā€™t crashing?

Right, my debug build with shared libraries does not crash. Iā€™ll try non-shared as Brad suggested and report back.

1 Like

Which information is not up-to-date ? See Documentation/Nightly/Developers/Factory - Slicer Wiki

What are you trying to do ?

I am not familiar with mac, and so I am not sure how the clang compiler interacts with the XCode setup (cmake finds the compiler through the xcode toolchain). I donā€™t know how the compiler is installed or from where.

The factory notes includes details about VMs on the mac machine which is very out of date for our current setup.

I can replicate the crash when I build in Debug with Slicer_USE_SimpleITK_SHARED:BOOL=OFF

Hereā€™s the stack trace. As suspected the dynamic case results in a null pointer.

Hereā€™s some more info on the object itā€™s trying to convert:

This is the compiler provided by XCode installed on the machine. I updated the page.

Thanks for testing Steve! That was a big help to help reproduce the issue.

I believe the following correction is needed, but my build has not finished the clean rebuild. The partial rebuild failed but the nm inspection of the _SimpleITK.so library indicated the symbols were exported as the prior working version.

diff --git a/SuperBuild/External_SimpleITK.cmake b/SuperBuild/External_SimpleITK.cmake
index 2e8f20106..cb3cd4710 100644
--- a/SuperBuild/External_SimpleITK.cmake
+++ b/SuperBuild/External_SimpleITK.cmake
@@ -88,7 +88,7 @@ ExternalProject_Execute(${proj} \"install\" \"${PYTHON_EXECUTABLE}\" Packaging/s
       -DSimpleITK_INSTALL_ARCHIVE_DIR:PATH=${Slicer_INSTALL_LIB_DIR}
       -DSimpleITK_INSTALL_LIBRARY_DIR:PATH=${Slicer_INSTALL_LIB_DIR}
       -DSimpleITK_INT64_PIXELIDS:BOOL=OFF
-      -DSimpleITK_EXPLICIT_INSTATIATION_DEFAULT:BOOL=ON
+      -DSimpleITK_EXPLICIT_INSTANTIATION:BOOL=ON
       -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
       -DSimpleITK_USE_SYSTEM_ITK:BOOL=ON
       -DITK_DIR:PATH=${ITK_DIR}
1 Like

Just changing the flag and rebuilding didnā€™t work, so Iā€™m deleting all my Simple* directories from the build tree and retrying.

Unfortunately setting -DSimpleITK_EXPLICIT_INSTATIATION:BOOL=ON didnā€™t work even after rebuilding all the SimpleITK code. It still crashes when I try to run a command in SimpleFilters.

Anything else to try?

Let us verify this build and installation as we have had problems getting a clear re-build of SimpleITK before.

To check the build SimpleITK library got install correctly and the symbols are as expected, please in the build directory run:

for f in $(find ./ -name _SimpleITK.\*.so); do nm -C $f | grep vtable\ for\ itk::ImageBase; echo "==>$f"; done

This should find the library in the SimpleITK-build directory and the one installed in Pythonā€™s site-packages.

This distinguishes between the working Slicers and the broken ones:

$ for f in $(find ./ -name _SimpleITK.\*.so); do nm -C $f | grep vtable\ for\ itk::ImageBase; echo "==>$f"; done
==>.//Slicer-2020-01-15.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK-1.3.0.dev527-py3.6-macosx-10.11-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so

00000000078234d8 D **vtable for itk::ImageBase** <1u>

0000000007823728 D **vtable for itk::ImageBase** <2u>

0000000007823978 D **vtable for itk::ImageBase** <3u>

==>.//Slicer-2019-12-28.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK-1.3.0rc2.dev260-py3.6-macosx-10.11-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so

==>.//Slicer-2020-01-30.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK-1.3.0.dev527-py3.6-macosx-10.11-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so

==>.//Slicer-2020-01-30.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK-1.3.0.dev527-py3.6-macosx-10.11-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so

SHould we just change this in the nightly build and see if it fixes the issue? (worst case it does not fix the problem on Mac and breaks Windows builds, too - but these should be OK for one day)

Here are my results. Iā€™ll try deleting these python installation versions and rebuild using the same settings (non-shared, with explicit instantiation).

rock:s pieper$ for f in $(find ./ -name _SimpleITK.\*.so); do nm -C $f | grep vtable\ for\ itk::ImageBase; echo "==>$f"; done
000000000e683328 s vtable for itk::ImageBase<1u>
000000000e02f0d0 s vtable for itk::ImageBase<2u>
000000000e02c5f0 s vtable for itk::ImageBase<3u>
000000000e279818 s vtable for itk::ImageBase<4u>
000000000df04660 s vtable for itk::ImageBase<5u>
==>.//python-install/lib/python3.6/site-packages/SimpleITK-1.3.0.dev527-py3.6-macosx-10.14-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so
==>.//python-install/lib/python3.6/site-packages/SimpleITK-1.3.0rc2.dev260-py3.6-macosx-10.14-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so
000000000e683328 s vtable for itk::ImageBase<1u>
000000000e02f0d0 s vtable for itk::ImageBase<2u>
000000000e02c5f0 s vtable for itk::ImageBase<3u>
000000000e279818 s vtable for itk::ImageBase<4u>
000000000df04660 s vtable for itk::ImageBase<5u>
==>.//SimpleITK-build/SimpleITK-build/Wrapping/Python/build/lib.macosx-10.14-x86_64-3.6/SimpleITK/_SimpleITK.cpython-36m-darwin.so

I would say yes, or we can wait until my build finishes.

I deleted and regenerated the files and this is what I get (slicer still crashes when I try to run a SimpleFilters operation).

rock:s pieper$ for f in $(find ./ -name _SimpleITK.\*.so); do nm -C $f | grep vtable\ for\ itk::ImageBase; echo "==>$f"; done
000000000e683328 s vtable for itk::ImageBase<1u>
000000000e02f0d0 s vtable for itk::ImageBase<2u>
000000000e02c5f0 s vtable for itk::ImageBase<3u>
000000000e279818 s vtable for itk::ImageBase<4u>
000000000df04660 s vtable for itk::ImageBase<5u>
==>.//python-install/lib/python3.6/site-packages/SimpleITK-1.3.0.dev527-py3.6-macosx-10.14-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so
000000000e683328 s vtable for itk::ImageBase<1u>
000000000e02f0d0 s vtable for itk::ImageBase<2u>
000000000e02c5f0 s vtable for itk::ImageBase<3u>
000000000e279818 s vtable for itk::ImageBase<4u>
000000000df04660 s vtable for itk::ImageBase<5u>
==>.//SimpleITK-build/SimpleITK-build/Wrapping/Python/build/lib.macosx-10.14-x86_64-3.6/SimpleITK/_SimpleITK.cpython-36m-darwin.so

I was able to get back to my build. The symbols of the library are as expected and match that of the working Slicer distribution:

Slicer]$ for f in $(find ./ -name _SimpleITK.\*.so); do nm -C $f | grep vtable\ for\ itk::ImageBase; echo "==>$f"; done
00000000114cf1b0 D vtable for itk::ImageBase<1u>
00000000114cf400 D vtable for itk::ImageBase<2u>
00000000114cf650 D vtable for itk::ImageBase<3u>
0000000010d2d280 d vtable for itk::ImageBase<4u>
0000000010a15170 d vtable for itk::ImageBase<5u>
==>.//python-install/lib/python3.6/site-packages/SimpleITK-1.3.0.dev527-py3.6-macosx-10.13-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so
00000000114cf1b0 D vtable for itk::ImageBase<1u>
00000000114cf400 D vtable for itk::ImageBase<2u>
00000000114cf650 D vtable for itk::ImageBase<3u>
0000000010d2d280 d vtable for itk::ImageBase<4u>
0000000010a15170 d vtable for itk::ImageBase<5u>
==>.//SimpleITK-build/SimpleITK-build/Wrapping/Python/build/lib.macosx-10.13-x86_64-3.6/SimpleITK/_SimpleITK.cpython-36m-darwin.so

Now, the from the GUI the python fails on `sitk.Image(10,10,sitk.sitkUInt8);

corrected
From the command line with PythonSlicer there are unresolved sysmbols, which I guess is expected:

 .//python-install/bin/PythonSlicer  -c  "import SimpleITK as sitk; sitk.Image(10,10,sitk.sitkUInt8);"
dyld: lazy symbol binding failed: Symbol not found: __ZN3itk11ImageRegionILj2EEC1Ev
  Referenced from: /scratch/blowekamp/Slicer/python-install/lib/python3.6/site-packages/SimpleITK-1.3.0.dev527-py3.6-macosx-10.13-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so
  Expected in: flat namespace

dyld: Symbol not found: __ZN3itk11ImageRegionILj2EEC1Ev
  Referenced from: /scratch/blowekamp/Slicer/python-install/lib/python3.6/site-packages/SimpleITK-1.3.0.dev527-py3.6-macosx-10.13-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so
  Expected in: flat namespace

error: [/scratch/blowekamp/Slicer/python-install/bin/./python] exit abnormally - Report the problem.

I compiled SimpleITK v1.2.4 with the currently Slicer environment. I got simular terminations as before.

I did attach lldb to a running Slicer process and entered sitk.Image(10,10,sitk.sitkUInt8):

This is the top of the stack trace I got:

 thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00000001063553ba dyld`__abort_with_payload + 10
    frame #1: 0x0000000106354bac dyld`abort_with_payload_wrapper_internal + 82
    frame #2: 0x0000000106354bde dyld`abort_with_payload + 9
    frame #3: 0x0000000106314a9d dyld`dyld::halt(char const*) + 343
    frame #4: 0x0000000106314bc7 dyld`dyld::fastBindLazySymbol(ImageLoader**, unsigned long) + 167
    frame #5: 0x00007fff7b20532e libdyld.dylib`dyld_stub_binder + 282
    frame #6: 0x000000016233f3c8 _SimpleITK.cpython-36m-darwin.so
    frame #7: 0x0000000152bd2c1a _SimpleITK.cpython-36m-darwin.so`void std::__1::__invoke_void_return_wrapper<void>::__call<std::__1::__bind<void (itk::simple::Image::*&)(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int), itk::simple::Image*&, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&, std::__1::placeholders::__ph<3> const&, std::__1::placeholders::__ph<4> const&, std::__1::placeholders::__ph<5> const&>&, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int>(std::__1::__bind<void (itk::simple::Image::*&)(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int), itk::simple::Image*&, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&, std::__1::placeholders::__ph<3> const&, std::__1::placeholders::__ph<4> const&, std::__1::placeholders::__ph<5> const&>&&&, unsigned int&&, unsigned int&&, unsigned int&&, unsigned int&&, unsigned int&&) [inlined] decltype(__f=0x00007ffeebeec2a8, __a0=0x00007ffeebeec2b8, __args=0x00007ffeebeebcfc, __args=0x00007ffeebeebcf8, __args=0x00007ffeebeebcf4, __args=0x00007ffeebeebcf0, __args=0x00007ffeebeebcec)).*fp(std::__1::forward<unsigned int, unsigned int, unsigned int, unsigned int, unsigned int>(fp1))) std::__1::__invoke<void (itk::simple::Image::*&)(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int), itk::simple::Image*&, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, void>(void (itk::simple::Image::*&&&)(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int), itk::simple::Image*&&&, unsigned int&&, unsigned int&&, unsigned int&&, unsigned int&&, unsigned int&&) at type_traits:4264

From googling, I believe this is due to missing symbols.

I was able to get the library working by setting ā€œCMAKE_CXX_VISIBILITY_PRESET=defaultā€ and disabling the SimpleITKā€™s explicit ITK library. This SimpleITK PR will be required.

Because all the ITK symbols are at the library interface now the size is much larger:

483M .//python-install/lib/python3.6/site-packages/SimpleITK-1.2.4-py3.6-macosx-10.13-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so

After strip -x:
296M .//python-install/lib/python3.6/site-packages/SimpleITK-1.2.4-py3.6-macosx-10.13-x86_64.egg/SimpleITK/_SimpleITK.cpython-36m-darwin.so

By comparison the SimpleITK pypi binary contains all ITK IO, but doesnā€™t expose any symbols. The library is much smaller:
179M .//lib/python3.6/site-packages/SimpleITK/_SimpleITK.cpython-36m-darwin.so

Nice Brad :+1:

Looks like that PR has been merged, so Iā€™ll try a local build.

This is what I am working on compiling locally:

The change of visibility likely is not needed on Linux and Windows ( Have we verified SimpleITK is working on them currently?), so to minimize size it may be best to only change the visibility on OSX.