OpenCASCADE, VTK integration Error in Debug Mode

Furkan Tuzemen

Looking around for some CAD
I am trying to render a OpenCascade shape using VTK and while setting the Input Connection to Mapper in VTK I am getting error.

vtkNew<IVtkTools_ShapeDataSource> occDataSource;
occDataSource->SetShape(new IVtkOCC_Shape(shape));
vtkNew<vtkPolyDataMapper> mapper;

Exception thrown at 0x00007FF8788B2DFA (msvcp140d.dll) in OcctVtkTutorialYoutube.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

However, this error is only happening in debug mode and not in Release mode.
My Occt version: OpenCASCADE-7.7.0-vc14-64
Vtk Version: 9.2


Staff member
Hi @Furkan Tuzemen

I was able to reproduce a similar problem to yours. There is a crash in the debug configuration and no such in release mode with using VTK. It was reproduced it on the same version of OpenCASCADE and VTK.

It was compiled VTK, then OpenCASCADE, activated ‘DRAWEXE’ project in VisualStudio and launched DRAW application. After, I run the next rows in the DRAW script (from the ‘testx/vtk/ivtk/display_mode’):



On the last row it crashed in Debug, OK in Release.
Doing some debug of it, the place was found. It crashes in next row of OpenCascade code in IVtkDraw.cxx:

It happens because ‘RenderWindow’ is null in the interactor although this window was set some rows above. Very strange…

Then I tried to debug it and deep down to VTK and discovered that compilation goes into release VTK libraries. I changed VisualStudio projects to have links to debug VTK libraries (just corrected manually Visual Studio projects). The result is NO crash, RenderWindow is filled, the code goes further. Now it becomes possible to continue execution of the next commands of this VTK test in DRAW and see the presentation in the viewer. There was no crash anymore thought it's the Debug configuration)

Therefore, it talks that we should use VTK debug libraries and DLLs for debug configuration. I checked this on given in the description version of VTK and OpenCascade, may be for earlier versions this condition was not obligate (official release of OpenCascade proposes another version of VTK using, see the

Here, I have not checked it on lesson 2 code from Youtube channel, but assume that this correction helps for it also. It would be very nice if you could check it by yourself and write whether it really helps)

Best regards, Natalia

Furkan Tuzemen

Looking around for some CAD
Hello @natalia

I'm sorry for the late reply. Thank you very much for your time and solution. I tried a few times but still had some problems running it in Debug.
Many times I had to compile VTK and OpenCascade in different ways to fully understand the problem. Finally, as you suggest, I was able to successfully run Draw.exe in Debug mode. I'm not entirely sure, but it's the common dlls in VTK and OpenCascade that don't work for me directly.

For example, Freetype and Tbb dlls are available in both OpenCASCADE and VTK. Therefore, when compiling both libraries, I made sure that they both use the same dlls in the common ones and that the Debug versions of these dlls are also available. So I was able to run it properly in Debug as well. I also made sure the Build With Debug option was selected when compiling libraries from source code with Cmake.

However, I am currently having some issues with running Debug along with Qt. I'm trying to figure out what exactly is causing the problem. If the problem is not related to the project I am running, I will ask in the forum for a solution.

A big thank you to you and the Quaoar team.
Best wishes, Furkan.