using vtkWarningMacro in a thread stops abruptly this last (vtkOutputWindow thread safety)

(Embeddedmz) #1


When I use vtkWarningMacro in another thread in my writer class in Catalyst, I don’t have any issues.

However, when I use my writer in ParaView, to save a result, vtkWarningMacro stops abruptly the thread launched by my writer, in other words : it crashes the thread !

When I was developing in C++ under Windows, I remember that a crash produced in a thread stops the whole application, here I don’t understand how a thread can be stopped abruptly and the program continue its execution.

In the callstack I can see that vtkOutputWindow is handled differently than in Catalyst (that’s normal, as messages are displayed in a widget).

I want to know why I can’t use vtkWarningMacro in a thread in ParaView client and how to fix that.


(Utkarsh Ayachit) #2

Is it possible to create a small example to reproduce this issue? If so, it would be great to report this on the issue tracker so we can track it down.

(Embeddedmz) #3

Here, I managed to freeze the app and crash the thread :

    #include <thread>
    #include <vtkObject.h>
    #include <vtkSetGet.h>
    #include <vtkNew.h>

    class DummyVtkObjectClass : public vtkObject
        static DummyVtkObjectClass* New();
        vtkTypeMacro(DummyVtkObjectClass, vtkObject)

        void PrintAndCrash() { vtkWarningMacro(<< "Crash this app now !"); }

    class myMainWindow : public QMainWindow {

        std::thread                 crashTestThread;
        vtkNew<DummyVtkObjectClass> testSubject;
        void CrashTestMethod()
            // pause until things get set up

    myMainWindow::myMainWindow(QWidget* parent)
        : QMainWindow(parent)
        , ui(new Ui::myMainWindow),
          crashTestThread(&myMainWindow::CrashTestMethod, this)

PS : it is possible to have a button to paste a C++ code in this board ???

(Utkarsh Ayachit) #4

Thanks, @embeddedmz. I’ll try it out later today.

I am not sure why you need that. You can always just enter any code by enclosing in it 3 ticks e.g. below:

int foo = 12;
class MyClass : public QWidget

written as:

int foo = 12;
class MyClass : public QWidget

(Mathieu Westphal) #5

There is a button anyway. Juste select some code and click on the “Preformated Text” button.

(Utkarsh Ayachit) #6

doesnt’ crash for me, I am afraid. Attached is the patch I used for ParaView’s default main window to emulate your code. My test was with ParaView latest release branch.

mainwindow.patch (2.2 KB)

(Embeddedmz) #7

I forgot to say that I am using Paraview 5.4.1 under Centos 7, apparently this issue disappeared in the latter versions !