# Crash Using Vtk in QML

**URL:** https://discourse.vtk.org/t/crash-using-vtk-in-qml/4250
**Category:** Support
**Created:** [September 18, 2020, 5:00pm UTC](https://discourse.vtk.org/t/crash-using-vtk-in-qml/4250 "2020-09-18T17:00:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![eustache](https://discourse.vtk.org/user_avatar/discourse.vtk.org/eustache/32/917_2.png) [@eustache](https://discourse.vtk.org/u/eustache)
#### Post date: [September 18, 2020, 5:00pm UTC](https://discourse.vtk.org/t/crash-using-vtk-in-qml/4250/1 "2020-09-18T17:00:16Z")

</div>

When migrating from qt5.9 vtk8 ubuntu 16 to qt5.15 vtk8 ubuntu 20 we started to have crashes within VTK when rendering the scene.  
We are using

> <https://gist.github.com/nocnokneo/c3fb01bb7ecaf437f7d6>
>
> There are more than three files. show original

  
Using vtk debug it looks like it’s pointing to this line: [https://gitlab.kitware.com/vtk/vtk/-/blob/master/Common/Transforms/vtkAbstractTransform.cxx#L712](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Common/Transforms/vtkAbstractTransform.cxx#L712)  
I am not sure where to start … any ideas?  
Our stack trace is the following:  
1 vtkTransformConcatenation::GetMaxMTime() 0x7ffff5e73354  
2 vtkTransform::GetMTime() 0x7ffff5e84dad  
3 vtkProp3D::GetUserTransformMatrixMTime() 0x7ffff6cc8bde  
4 vtkProp3D::GetMTime() 0x7ffff6cca34d  
5 vtkActor::GetMTime() 0x7ffff6c33773  
6 vtkProp3D::ComputeMatrix() 0x7ffff6cc91ab  
7 vtkOpenGLActor::GetKeyMatrices(vtkMatrix4x4 \*&, vtkMatrix3x3 \*&) 0x7ffff74240e0  
8 vtkOpenGLPolyDataMapper::SetCameraShaderParameters(vtkOpenGLHelper&, vtkRenderer \*, vtkActor \*) 0x7ffff746a582  
9 vtkOpenGLPolyDataMapper::UpdateShaders(vtkOpenGLHelper&, vtkRenderer \*, vtkActor \*) 0x7ffff747b0fe  
10 vtkOpenGLPolyDataMapper::RenderPieceDraw(vtkRenderer \*, vtkActor \*) 0x7ffff746aa42  
11 vtkOpenGLPolyDataMapper::RenderPiece(vtkRenderer \*, vtkActor \*) 0x7ffff747e254  
12 vtkPolyDataMapper::Render(vtkRenderer \*, vtkActor \*) 0x7ffff6cc7d03  
13 vtkActor::RenderOpaqueGeometry(vtkViewport \*) 0x7ffff6c330b7  
14 vtkRenderer::DeviceRenderOpaqueGeometry() 0x7ffff6cd553b  
15 vtkOpenGLRenderer::DeviceRenderOpaqueGeometry() 0x7ffff74995c8  
16 vtkOpenGLRenderer::UpdateGeometry() 0x7ffff7497778  
17 vtkOpenGLRenderer::DeviceRender() 0x7ffff7496474  
18 vtkRenderer::Render() 0x7ffff6cd8224  
19 vtkRendererCollection::Render() 0x7ffff6cd4490  
20 vtkRenderWindow::DoStereoRender() 0x7ffff6ce1215  
21 vtkRenderWindow::Render() 0x7ffff6ce34d6  
22 vtkGenericOpenGLRenderWindow::Render() 0x7ffff74213b1  
23 vtkInternalOpenGLRenderWindow::InternalRender vtkInternalOpenGLRenderWindow.cpp 41 0x555555629f78  
24 QVTKFramebufferObjectRenderer::render QVtkFramebufferObjectItem.cpp 51 0x555555629844  
25 ?? 0x7ffff4efb55a  
26 ?? 0x7ffff415f670  
27 QQuickWindowPrivate::renderSceneGraph(QSize const&, QSize const&) 0x7ffff4de45e7  
28 ?? 0x7ffff4d84b69  
29 ?? 0x7ffff4d88fb7  
30 ?? 0x7ffff3f3a14c  
31 start\_thread pthread\_create.c 477 0x7ffff361d609  
32 clone clone.S 95 0x7ffff3b67103

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [September 21, 2020, 4:13am UTC](https://discourse.vtk.org/t/crash-using-vtk-in-qml/4250/2 "2020-09-21T04:13:00Z")

</div>

It looks like you are accessing VTK objects from some worker thread. If you don’t prevent simultaneous access to the same VTK object from multiple threads then your application is expected to crash. It may also be a problem if you are not careful about activating and using OpenGL contexts in each thread.

---

<div class="post-metadata">

### Author: ![eustache](https://discourse.vtk.org/user_avatar/discourse.vtk.org/eustache/32/917_2.png) [@eustache](https://discourse.vtk.org/u/eustache)
#### Post date: [October 1, 2020, 1:51pm UTC](https://discourse.vtk.org/t/crash-using-vtk-in-qml/4250/3 "2020-10-01T13:51:06Z")

</div>

Thanks Andras, your hint was the correct one, we realized that in our new environment (ubuntu 20 + Qt5.15) we were accessing VTK objects from different threads at the same time (the main gui thread and the graph scene render thread). It looks like that in our previous environment (Ubuntu 16+Qt5.9) all that was happening in the same thread. So as a workaround for now we use QSG\_RENDER\_LOOP=basic, and no more crashes.  
I found this doc particularly useful: [https://doc.qt.io/qt-5/qtquick-visualcanvas-scenegraph.html](https://doc.qt.io/qt-5/qtquick-visualcanvas-scenegraph.html)
