Tips on debugging PyQt - pyqt4

I've got a PyQt4 project with a very weird error, under certain circumstances the main thread simply dies and I have no idea why.
No exception reported or shown, I've tried wrapping a try - except around app.exec_() and nothing.
sys.exit() is not called
Does anybody have any tips, is there a tool to see what signals/messages are passed around inside Qt or something else?

It is likely that the application is crashing in Qt. Try running the program with gdb.
gdb --args python myprog.py
When the program crashes, this should give you a backtrace that may shed some light on what is going on.
Note that having debug symbols available for Qt will make the backtrace more useful. On Ubuntu or Debian systems, the libqt4-dbg package can be installed to make these debug symbols available.

Reading the backtrace with gdb is the first step, as suggested (after the program crashes, type'backtrace' in gdb). In many cases, though, this will not lead to an obvious solution.
Here's a collection of things to look out for that cause crashes:
What are good practices for avoiding crashes / hangs in PyQt?

Related

Does anyone have an idea how to find what or who is calling findstr.exe to run speratically?

I have Windows 10, and about a week ago I installed Avast Device Driver Updater and it did update my chipset, intel processor, and Intel RAID drivers, which were the only ones I allowed it to with no problems. However a couple of days after I started noticing that a CMD window just pops up out of no where and seemingly when it wants to, and it runs a bunch of FINDSDR commands on a bunch of directories that I don't have on my laptop. The window then closes before I have a chance to read any of the paths and quicker then I can catch it to copy anything. The problem is that I can not find the program, shell script, or anything that would be running that might be causing this to run.
I do know that it always tries the to find the same directories, and they fail every time. But I just cant read them... I checked and according to Avast, the Driver Updater does not run any scripts like this, so it should not be the updater process, and just to be sure, I have stopped it from Auto Loading at Boot, and I turned off all it's functions in the settings.
So, I would like to know if anyone knows of any tricks that would help me identify what is calling the findstr.exe, or a way to trap it, while it's running (though even it I trapped it, I don't know how I can use that info to find the culprit that is causing it to run. I am hoping some one know how I can figure out what or where its running from and whos making it run. Any ideas? Thanks a bunch in advance!

How to avoid python termination against external dll crash?

I have loaded the ngspice shared spice circuit simulator (dll) in python using ctypes. I am running my simulations in the background thread of ngspice and I call ngspice_running() function to see if the simulation is still running.
So the problem is that when sometimes I input a wrong circuit, the program crashes. I think since I am still calling ngspice_running() function to check the status of the background thread, it makes my python kernel to die. I am using python exception statements to keep my program running but it is not so helpful in this case I guess.
How could I avoid this kernel death issue to keep my python program running as I cannot avoid inputting some wrong circuits? It would be great if someone could point me to the right direction.
Is there some way by which the program could return to certain line of code in python in case of external error from where the program cannot recover?
Thanks in advance!

How can I find a reason that a program stalls?

I'm handling a program which controls a car.
The program has a pretty large scale and it was made by other people.
So I don't understand completely how it works.
But I have to apply it and make a car moving.
The problem I'm facing is that the program often stalls with no error, no segmentation.
If it crashes, I can trace the cause with gdb or something like that.
But it does not crash, it silently stops.
How can I find the cause?
From your description - program silently stops - I understand that your program simply and gracefully exited, but not from your expected flow. This can happen for many reasons - for example, maybe your program enters illegal flow and some sub-component, such as standard library or other library decide that program should exit, and thus calls c-runtime exit() or directly calls Kernel32!ExitProcess().The best way to debug this flow is to attach a debugger and set a breakpoint on these two methods and find out who is calling them.If you mean your program enters a deadlock and halts then also you will need to attach a debugger and find out who is stuck.

Kernel died, restarting in the middle of my simulation (spyder)

I am using the spyder interface with a python script that works through many time steps in succession. At a random point in my code, the process will terminate and the console will say "kernel died, restarting...". I tried running the same script in pycharm and the process also terminates, seemingly at a random point, with some exit code which I assume means the same thing.
Anyone have any tips on how to get rid of this problem? Even a workaround so I can get some work done. This is incredibly frustrating.
Note: I recently moved and got a new router and internet service, not sure if that might affect things.

What do you do with badly behaving 3rd party processes in Linux?

Anytime I have a badly behaving process (pegging CPU, or frozen, or otherwise acting strangely) I generally kill it, restart it and hope it doesn't happen again.
If I wanted to explore/understand the problem (i.e. debug someone else's broken program as it's running) what are my options?
I know (generally) of things like strace, lsof, dmesg, etc. But I'm not really sure of the best way start poking around productively.
Does anyone have a systematic approach for getting to the bottom of these issues? Or general suggestions? Or is killing & restarting really the best one can do?
Thanks.
If you have debugging symbols of the program in question installed, you can attach to it with gdb and look what is wrong there. Start gdb, type attach pid where pid is the process id of the program in question (you can find it via top or ps). Then type Ctrl-C to stop it. Saying backtrace gives you the call stack, that means it tells which line of code is currently running and which functions called the currently running function.

Resources