[SOLVED] Application crashes when using vtkSmartVolumeMapper::New()

Issue

Crash happens in runtime on vtkSmartVolumeMapper::New() step.
And it goes deep to vtkFixedPointVolumeRayCastMapper constructor. Don’t understand how to tackle such an issue, please help

call stack

enter image description here

Exception thrown at 0x00007FF73A60735A in smop-ptqt.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

Qt 5.15.6, VTK 9.1.0, ITK 5.2.1

Solution

Finally fixed crash on vtkSmartVolumeMapper::New() by using VTK9’s new module approach in cmakelists.

So previously, while project used some vtk7.1 version.
CmakeLists treated VTK like this

find_package(VTK CONFIG REQUIRED PATHS "<some_path>/3rd_party/VTK/build/install_dir/lib/cmake/vtk-9.1" )

then used and so on.
target_link_libraries( ...${VTK_LIBRARIES} )

Now I applied module way

    find_package(VTK CONFIG REQUIRED 
    COMPONENTS
        GUISupportQt
        CommonCore
        ViewsCore
        ViewsInfovis
        DICOM
        RenderingCore
        RenderingLabel
        CommonExecutionModel
        RenderingOpenGL2
        InteractionWidgets
        IOPLY
        IOGeometry
        RenderingQt
        RenderingVolumeOpenGL2
        IOImport )

...


target_link_libraries(${PROJECT_NAME} ... 
        VTK::GUISupportQt
        VTK::CommonCore
        VTK::ViewsCore
        VTK::ViewsInfovis
        VTK::DICOM
        VTK::RenderingCore
        VTK::RenderingLabel
        VTK::CommonExecutionModel
        VTK::RenderingOpenGL2
        VTK::InteractionWidgets
        VTK::IOCore
        VTK::IOPLY
        VTK::IOGeometry
        VTK::RenderingQt
        VTK::RenderingVolumeOpenGL2
        VTK::IOImport
        )

...

    vtk_module_autoinit(
    TARGETS ${PROJECT_NAME}
    MODULES VTK::GUISupportQt
        VTK::CommonCore
        VTK::ViewsCore
        VTK::ViewsInfovis
        VTK::DICOM
        VTK::RenderingCore
        VTK::RenderingLabel
        VTK::CommonExecutionModel
        VTK::RenderingOpenGL2
        VTK::InteractionWidgets
        VTK::IOCore     
        VTK::IOPLY
        VTK::IOGeometry
        VTK::RenderingQt
        VTK::RenderingVolumeOpenGL2
        VTK::IOImport
        )

( was inspired by this script, thank you Qt-VTK-viewer developer(s) who worked on that script https://github.com/martijnkoopman/Qt-VTK-viewer/blob/master/CMakeLists.txt )

Answered By – Vadixem

Answer Checked By – Katrina (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *