How to debug silent crash
<p>I have a Python3.4 and PyQt5 application. This application communicate with an embedded device (Send and receive some frames).</p>

<p>I have a method (run from a QThread) to retrieve the device events ( It can be 10 events or more than 600 ). This methode work well in "release" mode.
But when I start the program in "debug" mode with Pycharm, it will work without breakpoint but will crash with the exit code 0 if I put a breakpoint.</p>

<p>I have a retry button to launch this process. 
So in release mode if I retry again and again it will also fail with the the exit code 0. </p>

<p>Moreover, the application doesn't crash each time at the same moment, if the amount of data to read from the device is large, the soft will crash earlier, else it will be longer.</p>

<p>So I was thinking about memory, but I can't catch any exception.
I tried to re-raise every exception in my program, nothing, so I tried to add thoses lines in my main :</p>

<pre><code>def on_exception_triggered(type_except, value, tb):
    import traceback
    trace = "".join(traceback.format_exception(type_except, value, tb))
    print("ERROR HOOKED : ", trace)
    sys.__excepthook__(type_except, value, tb)

sys.excepthook = on_exception_triggered
</code></pre>

<p>But it catch nothing more</p>

<p>Actually the best thing that you can do is try to make your code independent from pyqt and debug it look for issues fix them and make connection with pyqt, because otherwise even if your code works fine you will get just the interface on a screen and you can not see what happen </p>

python multithreading exception-handling pyqt pycharm