Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we integrate this to Multithreaded Application? #18

Open
vinayAtWork opened this issue Sep 15, 2022 · 3 comments
Open

Can we integrate this to Multithreaded Application? #18

vinayAtWork opened this issue Sep 15, 2022 · 3 comments
Labels

Comments

@vinayAtWork
Copy link

Hi,
Thanks for this tool, I have compiled it and it's working fine for the example project which is given in the repo.
But what I did is, from mainwindow.cpp I run one class into other thread and used the same function given in the example to crash the application on that thread.
But no log came after application crashes.
I want to use it for a multithreaded application, will this work?

@asmaloney
Copy link
Owner

You don't say what OS you're trying it on, but on macOS it reads like it should work. I am not in a position to test it at the moment.

Are you installing the signal handler on the main thread like in the example?

From man sigaction:

After a fork(2) or vfork(2) all signals, the signal mask, the signal stack, and the restart/interrupt flags are inherited by the child.

Further reading - Signal Handlers for Multithreaded C++:

Signals are delivered to any one thread that has not blocked the signal, including (and as a most likely candidate) the main thread.

So I'm not sure what that means for us if we are trying to display a QMessageBox (in the example) since it sounds like it could happen from any thread. I think that should be fine...

@vinayAtWork
Copy link
Author

Hi,
Sorry for not mentioning, I am using it on windows.
when I connected the start() of Qthread to one slot which will cause the crash. In this case it didn't work.
But when I run the class and connected start() into non crash function and then crash it after some time. That time it works so it is little confusing.

@asmaloney
Copy link
Owner

I'm having a hard time picturing what you're doing. Could you please show simple code snippets for the two cases?

I'm not very familiar with Windows stuff, but it's using SetUnhandledExceptionFilter which according to the docs:

Issuing SetUnhandledExceptionFilter replaces the existing top-level exception filter for all existing and all future threads in the calling process.

However it also says:

The exception handler specified by lpTopLevelExceptionFilter is executed in the context of the thread that caused the fault. This can affect the exception handler's ability to recover from certain exceptions, such as an invalid stack.

So maybe in one of your cases it's not in a state where it can do anything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants