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

Hello,

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.

Thanks.

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.

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
    {
    public:
        static DummyVtkObjectClass* New();
        vtkTypeMacro(DummyVtkObjectClass, vtkObject)

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

    class myMainWindow : public QMainWindow {
        Q_OBJECT

    public:
        std::thread                 crashTestThread;
        vtkNew<DummyVtkObjectClass> testSubject;
        void CrashTestMethod()
        {
            // pause until things get set up
            std::this_thread::sleep_for(std::chrono::seconds(30));
            testSubject->PrintAndCrash();
        }
    ...
    };

    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 ???

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:

```c++
int foo = 12;
class MyClass : public QWidget
{
};
```
1 Like

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

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)

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